mirror of
https://bitbucket.org/jsuto/piler.git
synced 2024-12-25 18:20:12 +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 *r;
|
||||
int len;
|
||||
|
||||
if(row == NULL)
|
||||
if(row == NULL || s == NULL)
|
||||
return NULL;
|
||||
|
||||
r = strchr(row, ch);
|
||||
if(r == NULL){
|
||||
len = strlen(row);
|
||||
if(len > size)
|
||||
len = size;
|
||||
}
|
||||
else {
|
||||
len = strlen(row) - strlen(r);
|
||||
if(len > size)
|
||||
len = size;
|
||||
if(r) *r = '\0';
|
||||
|
||||
snprintf(s, size, "%s", row);
|
||||
|
||||
if(r){
|
||||
*r = ch;
|
||||
r++;
|
||||
}
|
||||
|
||||
if(s != NULL){
|
||||
strncpy(s, row, len);
|
||||
s[len] = '\0';
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user