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

Bill Parker <[email protected]>
Newsgroups gmane.comp.security.ids.snort.devel
Message-ID <CAFrbyQxGkEO3s+ZuBMn2AxTtXx=YethreAf1H9dhSzYRR+anVQ@mail.gmail.com>
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
made.

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)

------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140

_______________________________________________
Snort-devel mailing list
[email protected]
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!
u2spewfoo.cc.patch (application/octet-stream, 479 B)
--- u2spewfoo.cc.orig	2016-02-04 09:52:45.165698498 -0800
+++ u2spewfoo.cc	2016-02-04 09:59:13.361036129 -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;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.