Missing Sanity Check for segment_calloc() in snort-3.0.0 Alpha 3

Bill Parker <[email protected]>
Newsgroups gmane.comp.security.ids.snort.devel
Message-ID <CAFrbyQwmA4G4kM92msvtZHEyQSBKA7p4dztDD_=9kR4jYWYEWg@mail.gmail.com>
Hello All,

In reviewing source code in sub-directory
'src/network_inspectors/reputation'
file 'reputation_parse' in function 'IpListInit' there is a call to
segment_calloc() which is not checked against variable/constant 'nullptr'
which could lead to additional issues in the white/black list entries.

The patch file below should address/correct this issue:

--- reputation_parse.cc.orig    2015-12-31 08:54:46.879515874 -0800
+++ reputation_parse.cc 2015-12-31 08:59:20.703317471 -0800
@@ -119,6 +119,10 @@
         }

         list_ptr = segment_calloc((size_t)DECISION_MAX, sizeof(ListInfo));
+       if (list_ptr == nullptr)
+       {
+           FatalError("Failed to allocate memory for white-black
lists.\n");
+       }
         config->iplist->list_info = list_ptr;

         config->local_black_ptr = list_ptr + BLACKLISTED *
sizeof(ListInfo);

=======================================================================

I am attaching the patch file to this bug report...

This issue does not appear to exist in
Snort-2.9.8.0/src/dynamic-preprocessors/
reputation, btw

Bill Parker (wp02855 at gmail dot com) <m0000000!>

------------------------------------------------------------------------------

_______________________________________________
Snort-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/snort-devel
Archive:
http://sourceforge.net/mailarchive/forum.php?forum_name=snort-devel

Please visit http://blog.snort.org for the latest news about Snort!
reputation_parse.cc.patch (application/octet-stream, 469 B)
--- reputation_parse.cc.orig	2015-12-31 08:54:46.879515874 -0800
+++ reputation_parse.cc	2015-12-31 08:59:20.703317471 -0800
@@ -119,6 +119,10 @@
         }
 
         list_ptr = segment_calloc((size_t)DECISION_MAX, sizeof(ListInfo));
+	if (list_ptr == nullptr)
+	{
+	    FatalError("Failed to allocate memory for white-black lists.\n");
+	}
         config->iplist->list_info = list_ptr;
 
         config->local_black_ptr = list_ptr + BLACKLISTED * sizeof(ListInfo);
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.