Browse code

bb11797 - fix invalid read in fuzzed mail file.

Steven Morgan authored on 2017/03/03 04:41:20
Showing 1 changed files
... ...
@@ -445,8 +445,12 @@ messageAddArgument(message *m, const char *arg)
445 445
 			 * FIXME: Bounce message handling is corrupting the in
446 446
 			 * core copies of headers
447 447
 			 */
448
-			cli_dbgmsg("Possible data corruption fixed\n");
449
-			p[8] = '=';
448
+                        if (strlen(p) > 8) {
449
+                            cli_dbgmsg("Possible data corruption fixed\n");
450
+                            p[8] = '=';
451
+                        } else {
452
+                            cli_dbgmsg("Possible data corruption not fixed\n");
453
+                        }
450 454
 		} else {
451 455
 			if(*p)
452 456
 				cli_dbgmsg("messageAddArgument, '%s' contains no '='\n", p);
... ...
@@ -682,7 +686,7 @@ messageFindArgument(const message *m, const char *variable)
682 682
 				cli_dbgmsg("messageFindArgument: no '=' sign found in MIME header '%s' (%s)\n", variable, messageGetArgument(m, i));
683 683
 				return NULL;
684 684
 			}
685
-			if((*++ptr == '"') && (strchr(&ptr[1], '"') != NULL)) {
685
+			if((strlen(ptr) > 2) && (*++ptr == '"') && (strchr(&ptr[1], '"') != NULL)) {
686 686
 				/* Remove any quote characters */
687 687
 				char *ret = cli_strdup(++ptr);
688 688
 				char *p;