[Snort-devel] Redundant call to fseek() in u2spewfoo.cc in Snort-3.0.0a3/a4

Bill Parker wp02855 at ...2499...
Thu Feb 4 16:41:28 EST 2016

Hello All,

In reviewing source code in snort-3.0.0a4, I found a redundant
call to fseek() in u2spewfoo.cc, which could be better written by
using a temporary variable to save the return value from fseek()
and checking that for a value < 0.  The patch file to address/correct
this is below:

--- u2spewfoo.cc.orig   2016-02-04 09:52:45.165698498 -0800
+++ u2spewfoo.cc        2016-02-04 09:55:41.211072960 -0800
@@ -105,8 +105,9 @@

     if ( s_off )
-        fseek(it->file, s_pos+s_off, SEEK_SET);
-        if (fseek(it->file, s_pos+s_off, SEEK_SET))
+        int result;
+        result = fseek(it->file, s_pos+s_off, SEEK_SET);
+        if (result < 0)
             puts("Unable to SEEK on current file .. and this is not being
handled yet.");
             return false;

this adjusts the code so that only a single call to fseek() is

This redundant call to fseek() is NOT present in Snort-2.9.7.x/2.9.8.x

I am 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/20160204/fb6f8b9e/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: u2spewfoo.cc.patch
Type: application/octet-stream
Size: 479 bytes
Desc: not available
URL: <https://lists.snort.org/pipermail/snort-devel/attachments/20160204/fb6f8b9e/attachment.obj>

More information about the Snort-devel mailing list