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

Russ Combs (rucombs) rucombs at ...3461...
Fri Dec 12 18:03:39 EST 2014


Thanks Bill.
________________________________
From: Bill Parker [wp02855 at ...2499...]
Sent: Friday, December 12, 2014 4:56 PM
To: snort-devel at lists.sourceforge.net
Subject: [Snort-devel] Missing Sanity Check for fseek() in Snort-3.0.0-a1

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)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.snort.org/pipermail/snort-devel/attachments/20141212/b1c4afe8/attachment.html>


More information about the Snort-devel mailing list