Skip to content

Commit

Permalink
messageAddArguments: accept argument values with unbalanced quotes
Browse files Browse the repository at this point in the history
If a quoted mime argument is unterminated, use all remaining line characters.
  • Loading branch information
monnerat authored and Mickey Sola (micksola) committed Oct 10, 2018
1 parent 3ffe2d6 commit 6c11e82
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions libclamav/message.c
Expand Up @@ -538,10 +538,10 @@ messageAddArguments(message *m, const char *s)
while(isspace(*string) && (*string != '\0'))
string++;

cptr = string++;
cptr = string;

if(strlen(key) == 0)
continue;
if (*string)
string++;

if(*cptr == '"') {
char *ptr, *kcopy;
Expand Down Expand Up @@ -582,7 +582,14 @@ messageAddArguments(message *m, const char *s)

data = cli_strdup(cptr);

ptr = (data) ? strchr(data, '"') : NULL;
if (!data) {
cli_dbgmsg("Can't parse header \"%s\" - if you believe this file contains a missed virus, report it to bugs@clamav.net\n", s);
free((char *)key);
return;
}

ptr = strchr(data, '"');

if(ptr == NULL) {
/*
* Weird e-mail header such as:
Expand All @@ -592,17 +599,11 @@ messageAddArguments(message *m, const char *s)
* Content-Disposition: attachment; filename="
* "
*
* TODO: the file should still be saved and
* virus checked
* Use the end of line as data.
*/
cli_dbgmsg("Can't parse header \"%s\" - if you believe this file contains a virus, submit it to www.clamav.net\n", s);
if(data)
free(data);
free(kcopy);
return;
}

*ptr = '\0';
}
else
*ptr = '\0';

datasz = strlen(kcopy) + strlen(data) + 2;
field = cli_realloc(kcopy, strlen(kcopy) + strlen(data) + 2);
Expand Down

0 comments on commit 6c11e82

Please sign in to comment.