enderunix / aget Goto Github PK
View Code? Open in Web Editor NEWMultithreaded HTTP Download Accelerator
Home Page: http://www.enderunix.org/aget/
License: Other
Multithreaded HTTP Download Accelerator
Home Page: http://www.enderunix.org/aget/
License: Other
To achieve successful compile on OS X, 10.7 - 10.10 you need to append the following CFLAG during the build process "-D_DARWIN_C_SOURCE"
.
Is that a known issue or something you guys upstream can fix?
It's an old bug, but I'm not sure if it was ever reported to anyone upstream and addressed, so apologies if this is belated or covering previously-trodden ground.
Hi,
There exist a heap buffer-overflow issue in revstr
function in Misc.c:146
. Space of size
is allocated for pointer p
in p = (char *)calloc(size, sizeof(char));
. However, the index used in for (i = size; i >= 0; i--, s++)
is out of bound.
void revstr(char *str)
{
char *p, *s;
int i;
int size;
if ((size = strlen(str)) == 0)
return;
p = (char *)calloc(size, sizeof(char));
s = p;
for (i = size; i >= 0; i--, s++)
*s = *(str + i - 1);
*s = '\0';
strncpy(str, p, size);
str[size] = '\0';
free(p);
}
To fix this bug, a patched version could be:
--- aget-master-new/Misc.c 2021-06-09 15:47:35.962171900 +0800
+++ aget-master/Misc.c 2021-06-09 15:48:13.950936000 +0800
@@ -140,9 +140,9 @@ void revstr(char *str)
if ((size = strlen(str)) == 0)
return;
- p = (char *)calloc(size, sizeof(char));
+ p = (char *)calloc(size+1, sizeof(char));
s = p;
- for (i = size; i >= 0; i--, s++)
+ for (i = size; i > 0; i--, s++)
*s = *(str + i - 1);
*s = '\0';
strncpy(str, p, size);
Here is the report from AddressSanitizer for this issue:
=================================================================
==5839==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x602000000017 at pc 0x55b0344b9c89 bp 0x7ffc1b493450 sp 0x7ffc1b493440
WRITE of size 1 at 0x602000000017 thread T0
#0 0x55b0344b9c88 in revstr /Aget-master/Misc.c:146
#1 0x55b0344b97de in parse_url /Aget-master/aget-devel/Misc.c:84
#2 0x55b0344b718e in main /Aget-master/aget-devel/main.c:108
#3 0x7f5f56cea0b2 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x270b2)
#4 0x55b0344b6a4d in _start (/Aget-master/aget-devel/aget+0x4a4d)
0x602000000017 is located 0 bytes to the right of 7-byte region [0x602000000010,0x602000000017)
allocated by thread T0 here:
#0 0x7f5f56fe5dc6 in calloc (/lib/x86_64-linux-gnu/libasan.so.5+0x10ddc6)
#1 0x55b0344b9bf4 in revstr /Aget-master/aget-devel/Misc.c:143
#2 0x55b0344b97de in parse_url /Aget-master/aget-devel/Misc.c:84
#3 0x55b0344b718e in main /Aget-master/aget-devel/main.c:108
#4 0x7f5f56cea0b2 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x270b2)
SUMMARY: AddressSanitizer: heap-buffer-overflow /Aget-master/aget-devel/Misc.c:146 in revstr
Shadow bytes around the buggy address:
0x0c047fff7fb0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0c047fff7fc0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0c047fff7fd0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0c047fff7fe0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0c047fff7ff0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
=>0x0c047fff8000: fa fa[07]fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c047fff8010: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c047fff8020: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c047fff8030: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c047fff8040: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c047fff8050: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
Shadow byte legend (one shadow byte represents 8 application bytes):
Addressable: 00
Partially addressable: 01 02 03 04 05 06 07
Heap left redzone: fa
Freed heap region: fd
Stack left redzone: f1
Stack mid redzone: f2
Stack right redzone: f3
Stack after return: f5
Stack use after scope: f8
Global redzone: f9
Global init order: f6
Poisoned by user: f7
Container overflow: fc
Array cookie: ac
Intra object redzone: bb
ASan internal: fe
Left alloca redzone: ca
Right alloca redzone: cb
Shadow gap: cc
==5839==ABORTING
Bazi *NIX sistemlerde (örnegin Mac OS) 'hostent' yapisi icerisinde kullanilan 'h_addr_list' icin bir yapi tanimlanmamistir. Bu problemi cözmek icin Head.h icerisine asagidaki kod eklenebilir:
patch:
index 215c2af..84465be 100644
--- a/Head.h
+++ b/Head.h
@@ -3,6 +3,10 @@
#include "Data.h"
+#ifndef h_addr
+#define h_addr h_addr_list[0]
+#endif
+
void http_head_req(struct request *);
#endif
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.