Snort mailing list archives

Missing Sanity Check for fseek() in Snort-3.0.0-a1


From: Bill Parker <wp02855 () gmail com>
Date: Fri, 12 Dec 2014 13:56:54 -0800

Hello All,

   In reviewing code in 'perf_base.cc' in directory
'/src/network_inspectors/perf_monitor'
for snort-3.0.0-a1, I found a call to fseek() which lacked a
test for a return value < 0, indicating failure.  The patch file
below adds the needed check and prints a warning message :)

--- perf_base.cc.orig   2014-12-12 13:47:19.386492263 -0800
+++ perf_base.cc        2014-12-12 13:49:51.404813010 -0800
@@ -1408,7 +1408,8 @@
         WarningMessage("Failed to write stats: %s\n", strerror(errno));

         // fseek to adjust offset; ftruncate doesn't do that for us.
-        fseek(fh, start, SEEK_SET);
+        if (fseek(fh, start, SEEK_SET) < 0) // fseek() failed for some
reason
+           WarningMessage("Failed to seek stats: %s\n", strerror(errno));

         if ( ftruncate(fileno(fh), start) )
             WarningMessage("Failed to truncate stats: %s\n",
strerror(errno));

I am attaching the patch file to this email.

Bill Parker (wp02855 at gmail dot com)

Attachment: perf_base.cc.patch
Description:

------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=164703151&iu=/4140/ostg.clktrk
_______________________________________________
Snort-devel mailing list
Snort-devel () lists sourceforge net
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!

Current thread: