fixed a buffer overflow when processing extremly long body lines

This commit is contained in:
SJ 2012-12-06 16:43:40 +01:00
parent 3073665cfe
commit 13534576df

View File

@ -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;
} }