mirror of
https://bitbucket.org/jsuto/piler.git
synced 2024-12-26 04:50:11 +01:00
fixed a buffer overflow when processing extremly long body lines
This commit is contained in:
parent
3073665cfe
commit
13534576df
22
src/misc.c
22
src/misc.c
@ -114,30 +114,20 @@ void replaceCharacterInBuffer(char *p, char from, char to){
|
|||||||
|
|
||||||
char *split(char *row, int ch, char *s, int size){
|
char *split(char *row, int ch, char *s, int size){
|
||||||
char *r;
|
char *r;
|
||||||
int len;
|
|
||||||
|
|
||||||
if(row == NULL)
|
if(row == NULL || s == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
r = strchr(row, ch);
|
r = strchr(row, ch);
|
||||||
if(r == NULL){
|
if(r) *r = '\0';
|
||||||
len = strlen(row);
|
|
||||||
if(len > size)
|
|
||||||
len = size;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
len = strlen(row) - strlen(r);
|
|
||||||
if(len > size)
|
|
||||||
len = size;
|
|
||||||
|
|
||||||
|
snprintf(s, size, "%s", row);
|
||||||
|
|
||||||
|
if(r){
|
||||||
|
*r = ch;
|
||||||
r++;
|
r++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(s != NULL){
|
|
||||||
strncpy(s, row, len);
|
|
||||||
s[len] = '\0';
|
|
||||||
}
|
|
||||||
|
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user