[flow-tools] Intermittent Header Bug in ftio.c ; recommended fix?

Mark Fullmer maf@splintered.net
Tue, 4 Jun 2002 23:09:17 -0400


Index: ftio.c
===================================================================
RCS file: /usr/home/djnz-cvsroot/flow-tools/lib/ftio.c,v
retrieving revision 1.38
diff -c -r1.38 ftio.c
*** ftio.c	26 May 2002 17:49:56 -0000	1.38
--- ftio.c	5 Jun 2002 03:06:09 -0000
***************
*** 1584,1598 ****
  
    fields = ftio->fth.fields;
  
-   streaming2 = (flags & FT_HEADER_FLAG_STREAMING);
-   if (flags & FT_HEADER_FLAG_PRELOADED)
-     streaming2 = 0;
- 
    if (fields & FT_FIELD_HEADER_FLAGS)
      flags = ftio->fth.flags;
    else 
      flags = 0;
  
  
    if (flags & FT_HEADER_FLAG_STREAMING)
      fprintf(std, "%c\n%c mode:                 streaming\n", cc, cc);
--- 1584,1597 ----
  
    fields = ftio->fth.fields;
  
    if (fields & FT_FIELD_HEADER_FLAGS)
      flags = ftio->fth.flags;
    else 
      flags = 0;
  
+   streaming2 = (flags & FT_HEADER_FLAG_STREAMING);
+   if (flags & FT_HEADER_FLAG_PRELOADED)
+     streaming2 = 0;
  
    if (flags & FT_HEADER_FLAG_STREAMING)
      fprintf(std, "%c\n%c mode:                 streaming\n", cc, cc);

mark

On Tue, Jun 04, 2002 at 07:17:09PM -0400, Dutky, Steve wrote:
> Please note varible flags referenced before it is initialized:
> 
> void ftio_header_print(struct ftio *ftio, FILE *std, char cc)
> {
>   struct ftiheader *fth;
>   struct ftmap_ifname *ftmin;
>   struct ftmap_ifalias *ftmia;
>   char agg_ver, agg_method;
>   char *agg_name;
>   char fmt_buf[32];
>   u_int32 flags, fields;
>   u_long period;
>   int n, streaming2;
> 
>   fth = &ftio->fth;
> 
>   fields = ftio->fth.fields;
> !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
>   streaming2 = (flags & FT_HEADER_FLAG_STREAMING);
>   if (flags & FT_HEADER_FLAG_PRELOADED)
>     streaming2 = 0;
> 
>   if (fields & FT_FIELD_HEADER_FLAGS)
>     flags = ftio->fth.flags;
>   else
> !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
> ...
> from ftio.c
> 
> 
> results in most of the time:
> $ flow-stat -p <./flow/2002/2002-06/2002-06-04/ft-v05.2002-06-04.091501-0400
> >
> #  --- ---- ---- Report Information --- --- ---
> #
> # Fields:    Total
> # Symbols:   Disabled
> # Sorting:   None
> # Name:      Overall Summary
> #
> # Args:      flow-stat -p 
> #
> #
> # mode:                 normal
> # capture hostname:     admin1
> # exporter IP address:  0.0.0.0
> # capture start:        Tue Jun  4 09:15:01 2002
> # capture end:          Tue Jun  4 09:30:01 2002
> # capture period:       900 seconds
> # compress:             off
> # byte order:           big
> # stream version:       3
> # export version:       5
> # lost flows:           0
> # corrupt packets:      0
> # sequencer resets:     0
> # capture flows:        23010
> #
> 
> 
> but sometimes:
> 
> $ flow-stat -p <./flow/2002/2002-06/2002-06-04/ft-v05.2002-06-04.091501-0400
> >
> #  --- ---- ---- Report Information --- --- ---
> #
> # Fields:    Total
> # Symbols:   Disabled
> # Sorting:   None
> # Name:      Overall Summary
> #
> # Args:      flow-stat -p 
> #
> #
> # mode:                 normal
> # capture hostname:     admin1
> # exporter IP address:  0.0.0.0
> # compress:             off
> # byte order:           big
> # stream version:       3
> # export version:       5
> #
> 
> 
> thanks, Steve Dutky
> 301-545-4113
> 
> _______________________________________________
> flow-tools@splintered.net
> http://www.splintered.net/sw/flow-tools