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

Bill Parker wp02855 at ...2499...
Fri Dec 12 16:56:54 EST 2014

Hello All,

   In reviewing code in 'perf_base.cc' in directory
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
+           WarningMessage("Failed to seek stats: %s\n", strerror(errno));

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

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/6bbfff0b/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: perf_base.cc.patch
Type: application/octet-stream
Size: 598 bytes
Desc: not available
URL: <https://lists.snort.org/pipermail/snort-devel/attachments/20141212/6bbfff0b/attachment.obj>

More information about the Snort-devel mailing list