Browse code

Fixes null-dereference in mail message parser.

Micah Snyder authored on 2019/11/01 05:05:29
Showing 2 changed files
... ...
@@ -3,7 +3,7 @@
3 3
  *  Copyright (C) 2007-2013 Sourcefire, Inc.
4 4
  *
5 5
  *  Authors: Nigel Horne
6
- * 
6
+ *
7 7
  *  Acknowledgements: Some ideas came from Stephen White <stephen@earth.li>,
8 8
  *                    Michael Dankov <misha@btrc.ru>, Gianluigi Tiesi <sherpya@netfarm.it>,
9 9
  *                    Everton da Silva Marques, Thomas Lamy <Thomas.Lamy@in-online.net>,
... ...
@@ -586,7 +586,7 @@ cli_parse_mbox(const char *dir, cli_ctx *ctx)
586 586
 		 */
587 587
 		messageDestroy(body);
588 588
 	}
589
-	
589
+
590 590
 	if((retcode == CL_CLEAN) && ctx->found_possibly_unwanted &&
591 591
 	   (*ctx->virname == NULL || SCAN_ALLMATCHES)) {
592 592
 	    retcode = cli_append_virus(ctx, "Heuristics.Phishing.Email");
... ...
@@ -1840,8 +1840,8 @@ parseEmailBody(message *messageIn, text *textIn, mbox_ctx *mctx, unsigned int re
1840 1840
 						 * must be listed here */
1841 1841
 						break;
1842 1842
 					default:
1843
-						/* this is a subtype that we 
1844
-						 * don't handle anyway, 
1843
+						/* this is a subtype that we
1844
+						 * don't handle anyway,
1845 1845
 						 * don't store */
1846 1846
 						if(messages[multiparts]) {
1847 1847
 							messageDestroy(messages[multiparts]);
... ...
@@ -3617,7 +3617,7 @@ getline_from_mbox(char *buffer, size_t buffer_len, fmap_t *map, size_t *at)
3617 3617
     src = cursrc = fmap_need_off_once(map, *at, input_len);
3618 3618
 
3619 3619
 /*	we check for eof from the result of GETC()
3620
- *	if(feof(fin)) 
3620
+ *	if(feof(fin))
3621 3621
 		return NULL;*/
3622 3622
     if(!src) {
3623 3623
 	cli_dbgmsg("getline_from_mbox: fmap need failed\n");
... ...
@@ -3629,7 +3629,7 @@ getline_from_mbox(char *buffer, size_t buffer_len, fmap_t *map, size_t *at)
3629 3629
     }
3630 3630
 
3631 3631
     curbuf = buffer;
3632
-	
3632
+
3633 3633
     for(i=0; i<buffer_len-1; i++) {
3634 3634
 	char c;
3635 3635
 
... ...
@@ -3666,7 +3666,7 @@ getline_from_mbox(char *buffer, size_t buffer_len, fmap_t *map, size_t *at)
3666 3666
     }
3667 3667
     *at += cursrc - src;
3668 3668
     *curbuf = '\0';
3669
-    
3669
+
3670 3670
     return buffer;
3671 3671
 }
3672 3672
 
... ...
@@ -3873,7 +3873,7 @@ do_multipart(message *mainMessage, message **messages, int i, mbox_status *rc, m
3873 3873
 
3874 3874
 		thisobj = messageGetJObj(aMessage);
3875 3875
 		if (thisobj == NULL) {
3876
-			cli_errmsg("Cannot get message preclass object\n");
3876
+			cli_dbgmsg("Cannot get message preclass object\n");
3877 3877
 			*rc = -1;
3878 3878
 			return mainMessage;
3879 3879
 		}
... ...
@@ -2649,7 +2649,9 @@ isuuencodebegin(const char *line)
2649 2649
 #if HAVE_JSON
2650 2650
 json_object *messageGetJObj(message *m)
2651 2651
 {
2652
-	assert(m != NULL);
2652
+    if (m == NULL) {
2653
+        return NULL;
2654
+    }
2653 2655
 
2654 2656
 	if(m->jobj == NULL)
2655 2657
 		m->jobj = cli_jsonobj(NULL, NULL);