[Snort-devel] [SNORT-DEVEL] Fix memory leak in Snort 2.9.7.0-alpha

Bill Parker wp02855 at ...2499...
Sun May 18 18:55:40 EDT 2014


Hi All,

   In reviewing file 'luaDetectorApi.c' in directory
'snort-2.9.7.0.alpha/src/dynamic-preprocessors/appid', I found
a small memory leak involving variable 'schemePattern' where
the memory isn't released due to a strdup() call failing.

The patch file is listed below:

--- luaDetectorApi.c.orig       2014-03-09 18:35:09.650653721 -0700
+++ luaDetectorApi.c    2014-05-17 19:44:33.408223503 -0700
@@ -2102,6 +2120,14 @@
     if(tmpString  && queryPatternSize)
     {
         queryPattern = (u_int8_t*) strdup(tmpString);
+       if (!queryPattern)
+       {
+           _dpd.errMsg( "Invalid query pattern string.");
+           free(pathPattern);
+           free(hostPattern);
+           free(schemePattern);
+           return 0;
+       }
     }

     u_int32_t appId           = lua_tointeger(L, index++);

The free(schemePattern); was left out of the previously submitted
patch for this file (my bad) <duh>.

I'm attaching the patch file to this bug report.

Bill Parker (wp02855 at gmail dot com)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.snort.org/pipermail/snort-devel/attachments/20140518/49d74781/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: luaDetectorApi.c.patch
Type: application/octet-stream
Size: 488 bytes
Desc: not available
URL: <https://lists.snort.org/pipermail/snort-devel/attachments/20140518/49d74781/attachment.obj>


More information about the Snort-devel mailing list