Hey all.
As I said in my previous mail, here they are. Patches, patches,
patches. Feel free to use it, because without those the thing is
unusable.
And if you are using fedora, just do "yum install flow-tools",
instead.
Enjoy!
--
Paul P 'Stingray' Komkoff Jr // http://stingr.net/key <- my pgp key
This message represents the official view of the voices in my head
>From nobody Mon Sep 17 00:00:00 2001
From: Paul P Komkoff Jr <[EMAIL PROTECTED]>
Date: Sat, 10 Jun 2006 20:45:55 +0400
Subject: [PATCH 1/8] Fix first line of included python scripts.
We need to do this to allow execution on FHS-compliant systems.
---
bin/flow-log2rrd | 2 +-
bin/flow-rpt2rrd | 2 +-
bin/flow-rptfmt | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
250b73e99e719fdeb26140e7f8ebab68963e243b
diff --git a/bin/flow-log2rrd b/bin/flow-log2rrd
index 0567ba5..db4fdda 100755
--- a/bin/flow-log2rrd
+++ b/bin/flow-log2rrd
@@ -1,4 +1,4 @@
-#!/usr/local/bin/python
+#!/bin/env python
import getopt
import os
diff --git a/bin/flow-rpt2rrd b/bin/flow-rpt2rrd
index 72a74c7..7698f2b 100755
--- a/bin/flow-rpt2rrd
+++ b/bin/flow-rpt2rrd
@@ -1,4 +1,4 @@
-#!/usr/local/bin/python
+#!/bin/env python
import getopt
import os
diff --git a/bin/flow-rptfmt b/bin/flow-rptfmt
index 047d1ba..f663fae 100755
--- a/bin/flow-rptfmt
+++ b/bin/flow-rptfmt
@@ -1,4 +1,4 @@
-#!/usr/local/bin/python
+#!/bin/env python
import sys
import string
--
1.3.3
>From nobody Mon Sep 17 00:00:00 2001
From: Paul P Komkoff Jr <[EMAIL PROTECTED]>
Date: Sat, 10 Jun 2006 20:49:45 +0400
Subject: [PATCH 2/8] Fix an "invalid lvalue in assignment" compile error.
---
lib/ftchash.c | 2 +-
lib/ftio.c | 4 ++--
lib/ftlib.h | 3 ++-
lib/fttlv.c | 34 +++++++++++++++++-----------------
lib/support.c | 5 +++++
5 files changed, 27 insertions(+), 21 deletions(-)
075301dae1b92110e6cc339b0df88b7fc82c31a6
diff --git a/lib/ftchash.c b/lib/ftchash.c
index 9cc7efa..28bafbf 100644
--- a/lib/ftchash.c
+++ b/lib/ftchash.c
@@ -326,7 +326,7 @@ void *ftchash_foreach(struct ftchash *ft
(char*)ftch->traverse_chunk->base+ftch->traverse_chunk->next) {
ret = ftch->traverse_rec;
- (char*)ftch->traverse_rec += ftch->d_size;
+ ftch->traverse_rec = vpadd(ftch->traverse_rec, ftch->d_size);
return ret;
} else {
diff --git a/lib/ftio.c b/lib/ftio.c
index f6c739c..1082416 100644
--- a/lib/ftio.c
+++ b/lib/ftio.c
@@ -2267,7 +2267,7 @@ int readn(register int fd, register void
break;
nleft -= nread;
- (char*)ptr += nread;
+ ptr = vpadd(ptr, nread);
}
return (nbytes - nleft);
} /* readn */
@@ -2292,7 +2292,7 @@ int writen(register int fd, register voi
return(nwritten); /* error */
nleft -= nwritten;
- (char*)ptr += nwritten;
+ ptr = vpadd(ptr,nwritten);
}
return(nbytes - nleft);
} /* writen */
diff --git a/lib/ftlib.h b/lib/ftlib.h
index f91ad0a..66bf2f3 100644
--- a/lib/ftlib.h
+++ b/lib/ftlib.h
@@ -152,7 +152,6 @@ #define FT_PDU_V8_11_MAXFLOWS 44 /* max
#define FT_PDU_V8_12_MAXFLOWS 44 /* max records in V8 DST_PREFIX_TOS packet */
#define FT_PDU_V8_13_MAXFLOWS 35 /* max records in V8 PREFIX_TOS packet */
#define FT_PDU_V8_14_MAXFLOWS 35 /* max records in V8 PREFIX_PORT_TOS packet
*/
-
#define FT_PDU_V8_1_VERSION 2 /* version of AS packet */
#define FT_PDU_V8_2_VERSION 2 /* version of PROTO PORT packet */
#define FT_PDU_V8_3_VERSION 2 /* version of SRC PREFIX packet */
@@ -3029,6 +3028,8 @@ #ifndef IN_CLASSD_SSM
#define IN_CLASSD_SSM(i) (((u_int32_t)(i) & 0xff000000) == 0xe8000000)
#endif /* IN_CLASSD_SSM */
+void *vpadd(const void* v, const int change);
+
/* MACHINE DEPENDANT */
#define fmt_uint fmt_uint32
diff --git a/lib/fttlv.c b/lib/fttlv.c
index 7035813..330a783 100644
--- a/lib/fttlv.c
+++ b/lib/fttlv.c
@@ -68,10 +68,10 @@ int fttlv_enc_uint32(void *buf, int buf_
}
bcopy(&t, buf, 2);
- (char*)buf+= 2;
+ buf = vpadd(buf, 2);
bcopy(&len, buf, 2);
- (char*)buf+= 2;
+ buf = vpadd(buf, 2);
bcopy(&v, buf, 4);
@@ -107,10 +107,10 @@ int fttlv_enc_uint16(void *buf, int buf_
}
bcopy(&t, buf, 2);
- (char*)buf+= 2;
+ buf = vpadd(buf, 2);
bcopy(&len, buf, 2);
- (char*)buf+= 2;
+ buf = vpadd(buf, 2);
bcopy(&v, buf, 2);
@@ -145,10 +145,10 @@ int fttlv_enc_uint8(void *buf, int buf_s
}
bcopy(&t, buf, 2);
- (char*)buf+= 2;
+ buf = vpadd(buf, 2);
bcopy(&len, buf, 2);
- (char*)buf+= 2;
+ buf = vpadd(buf, 2);
bcopy(&v, buf, 1);
@@ -183,10 +183,10 @@ int fttlv_enc_str(void *buf, int buf_siz
}
bcopy(&t, buf, 2);
- (char*)buf+= 2;
+ buf = vpadd(buf, 2);
bcopy(&len, buf, 2);
- (char*)buf+= 2;
+ buf = vpadd(buf, 2);
bcopy(v, buf, len);
@@ -230,16 +230,16 @@ int fttlv_enc_ifname(void *buf, int buf_
return -1;
bcopy(&t, buf, 2);
- (char*)buf+= 2;
+ buf = vpadd(buf, 2);
bcopy(&len, buf, 2);
- (char*)buf+= 2;
+ buf = vpadd(buf, 2);
bcopy(&ip, buf, 4);
- (char*)buf += 4;
+ buf = vpadd(buf, 4);
bcopy(&ifIndex, buf, 2);
- (char*)buf += 2;
+ buf = vpadd(buf, 2);
bcopy(name, buf, n);
@@ -287,19 +287,19 @@ int fttlv_enc_ifalias(void *buf, int buf
}
bcopy(&t, buf, 2);
- (char*)buf+= 2;
+ buf = vpadd(buf, 2);
bcopy(&len, buf, 2);
- (char*)buf+= 2;
+ buf = vpadd(buf, 2);
bcopy(&ip, buf, 4);
- (char*)buf += 4;
+ buf = vpadd(buf, 4);
bcopy(&entries, buf, 2);
- (char*)buf += 2;
+ buf = vpadd(buf, 2);
bcopy(ifIndex_list, buf, esize);
- (char*)buf += esize;
+ buf = vpadd(buf, esize);
bcopy(name, buf, n);
diff --git a/lib/support.c b/lib/support.c
index a32ffe7..2e1db9f 100644
--- a/lib/support.c
+++ b/lib/support.c
@@ -736,3 +736,8 @@ int udp_cksum(struct ip *ip, struct udph
return sum;
} /* udp_cksum */
+// void pointer add
+
+void * vpadd(const void *v, const int change) {
+ return (void *) (((char*) v) + change);
+}
--
1.3.3
>From nobody Mon Sep 17 00:00:00 2001
From: Paul P Komkoff Jr <[EMAIL PROTECTED]>
Date: Sat, 10 Jun 2006 20:51:50 +0400
Subject: [PATCH 3/8] Avoid external "debug" variable.
When buildinf flow-tools as bunch of binaries depending on shared library,
extern int debug shows in too much places. Disable it for now until better
solution will be developed.
---
lib/ftfile.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
1707e321511feb9b7cb117fb6be4d8bcfa8996de
diff --git a/lib/ftfile.c b/lib/ftfile.c
index 2f3ae76..f25e849 100644
--- a/lib/ftfile.c
+++ b/lib/ftfile.c
@@ -53,7 +53,7 @@ #endif
int load_dir(char *prefix, struct ftfile_entries *fte, int flags, int *depth);
-extern int debug;
+#define debug 0
/*
* function: ftfile_entry_new
--
1.3.3
>From nobody Mon Sep 17 00:00:00 2001
From: Paul P Komkoff Jr <[EMAIL PROTECTED]>
Date: Sat, 10 Jun 2006 20:53:33 +0400
Subject: [PATCH 4/8] Make flow-tools more FHS-compliant and buildable by newer
toolchain.
Here we are switching to new toolchain (autoconf, automake & libtool),
changing some paths (obviously config files should be put in sysconfdir -
usually etc - and not in localstatedir which is var)
---
configs/Makefile.am | 4 ++--
configure.in | 45 ++++++++++++++++++++++++++++++---------------
lib/Makefile.am | 10 +++++-----
lib/ftpaths.h.in | 22 +++++++++++-----------
src/Makefile.am | 12 ++++++------
5 files changed, 54 insertions(+), 39 deletions(-)
b03c8b4e55c5f6082ff427559ae5a8bc3e95b8f0
diff --git a/configs/Makefile.am b/configs/Makefile.am
index 9b06b52..6ca85cc 100644
--- a/configs/Makefile.am
+++ b/configs/Makefile.am
@@ -1,6 +1,6 @@
-ftsymdir=$(localstatedir)/sym
+ftsymdir=$(sysconfdir)/sym
ftsym_DATA = ip-prot.sym ip-type.sym tcp-port.sym asn.sym tag.sym
-ftcfgdir=$(localstatedir)/cfg
+ftcfgdir=$(sysconfdir)/cfg
ftcfg_DATA = map.cfg tag.cfg filter.cfg stat.cfg mask.cfg xlate.cfg
diff --git a/configure.in b/configure.in
index 01987e8..597bbbd 100644
--- a/configure.in
+++ b/configure.in
@@ -1,31 +1,32 @@
dnl Process this file with autoconf to produce a configure script.
-AC_INIT(lib/bit1024.c)
+AC_INIT(flow-tools, 0.68)
-AC_PREFIX_DEFAULT(/usr/local/netflow)
+AC_PREFIX_DEFAULT(/usr/local/flow-tools)
-AM_INIT_AUTOMAKE(flow-tools, 0.68)
-AM_CONFIG_HEADER(lib/ftconfig.h:lib/ftconfig.h.in)
+AM_INIT_AUTOMAKE
+AM_CONFIG_HEADER(lib/ftconfig.h)
-CFLAGS="-g -Wall"
+dnl CFLAGS="-g -Wall"
dnl Checks for programs.
+AC_PROG_LIBTOOL
AC_PROG_CC
AC_PROG_INSTALL
AC_PROG_MAKE_SET
AC_PROG_YACC
YACC="$YACC -d"
-AC_PROG_RANLIB
AM_PROG_LEX
AC_SUBST(YLIB)
AC_SUBST(MYSQLLIB)
AC_SUBST(MYSQLCFLAGS)
-AC_SUBST(MYSQLINCLUDE)
+AC_SUBST(MYSQLLDFLAGS)
AC_SUBST(PGSQLLIB)
AC_SUBST(PGSQLCFLAGS)
-AC_SUBST(PGSQLINCLUDE)
+AC_SUBST(PGSQLLDFLAGS)
AC_SUBST(CRYPTOLIB)
AC_SUBST(OPENSSLINCLUDE)
+AC_SUBST(OPENSSLLDFLAGS)
dnl extra argument: --with-mysql
WITH_MYSQL=
@@ -66,37 +67,51 @@ AC_ARG_WITH(openssl,
dnl Checks for libraries.
if test "x$WHERE_MYSQL" != "x"; then
- LIBS="-L$WHERE_MYSQL/lib/mysql"
+ old_LIBS="$LIBS"
+ old_LDFLAGS="$LDFLAGS"
+ LDFLAGS="$LDFLAGS -L$WHERE_MYSQL/lib/mysql"
AC_CHECK_LIB(mysqlclient, my_init,
[
- MYSQLCFLAGS="-L$WHERE_MYSQL/lib/mysql -I$WHERE_MYSQL/include/mysql"
+ MYSQLCFLAGS="-I$WHERE_MYSQL/include/mysql"
+ MYSQLLDFLAGS="-L$WHERE_MYSQL/lib/mysql"
MYSQLLIB="-lmysqlclient"
AC_DEFINE(HAVE_MYSQL)
]
)
+ LIBS="$old_LIBS"
+ LDFLAGS="$old_LDFLAGS"
fi
if test "x$WHERE_OPENSSL" != "x"; then
- LIBS="-L$WHERE_OPENSSL/lib"
+ old_LIBS="$LIBS"
+ old_LDFLAGS="$LDFLAGS"
+ LDFLAGS="$LDFLAGS -L$WHERE_OPENSSL/lib"
AC_CHECK_LIB(crypto, EVP_EncryptUpdate,
[
- OPENSSLCFLAGS="-L$WHERE_OPENSSL/lib -I$WHERE_OPENSSL/include"
+ OPENSSLCFLAGS="-I$WHERE_OPENSSL/include"
+ OPENSSLLDFLAGS="-L$WHERE_OPENSSL/lib"
CRYPTOLIB="-lcrypto"
AC_DEFINE(HAVE_OPENSSL)
]
)
+ LIBS="$old_LIBS"
+ LDFLAGS="$old_LDFLAGS"
fi
-
if test "x$WHERE_PGSQL" != "x"; then
- LIBS="-L$WHERE_PGSQL/lib/pgsql"
+ old_LIBS="$LIBS"
+ old_LDFLAGS="$LDFLAGS"
+ LDFLAGS="-L$WHERE_PGSQL/lib/pgsql"
AC_CHECK_LIB(pq, PQsetdbLogin,
[
- PGSQLCFLAGS="-L$WHERE_PGSQL/lib -I$WHERE_PGSQL/include/pgsql"
+ PGSQLCFLAGS="-I$WHERE_PGSQL/include/pgsql"
+ PGSQLLDFLAGS="-L$WHERE_PGSQL/lib"
PGSQLLIB="-lpq"
AC_DEFINE(HAVE_PGSQL)
]
)
+ LIBS="$old_LIBS"
+ LDFLAGS="$old_LDFLAGS"
fi
AC_CHECK_LIB(y, main,YLIB="$YLIB -ly",)
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 08e684a..5a4727b 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -2,17 +2,17 @@ ## Process this file with automake to pr
#AM_CFLAGS=-g -Wall -Wpointer-arith -Wstrict-prototypes -Wmissing-prototypes
-Wmissing-declarations -Wredundant-decls -Wnested-externs
#AM_CFLAGS=-O2
-AM_CFLAGS=-g -Wall
+#AM_CFLAGS=-g -Wall
-DEFS=-I. -I$(srcdir)/lib
+#DEFS=-I. -I$(srcdir)/lib
include_HEADERS = ftlib.h ftqueue.h radix.h ftpaths.h ftconfig.h
-lib_LIBRARIES = libft.a
+lib_LTLIBRARIES = libft.la
-libft_a_SOURCES = ftio.c ftswap.c ftencode.c ftdecode.c ftprof.c bit1024.c \
+libft_la_SOURCES = ftio.c ftswap.c ftencode.c ftdecode.c ftprof.c bit1024.c \
fmt.c support.c ftfile.c fttlv.c ftmap.c ftrec.c fterr.c \
ftchash.c ftsym.c radix.c fttag.c ftfil.c ftstat.c getdate.c ftxfield.c\
ftmask.c ftvar.c ftxlate.c
-libft_a_LIBADD = @LIBOBJS@
+libft_la_LIBADD = $(LTLIBOBJS) $(CRYPTOLIB)
diff --git a/lib/ftpaths.h.in b/lib/ftpaths.h.in
index ae8e30a..b0c91b1 100644
--- a/lib/ftpaths.h.in
+++ b/lib/ftpaths.h.in
@@ -29,17 +29,17 @@
#ifndef FTPATHS_H
#define FTPATHS_H
-#define FT_PATH_CFG_MAP "@localstatedir@/cfg/map.cfg"
-#define FT_PATH_CFG_TAG "@localstatedir@/cfg/tag.cfg"
-#define FT_PATH_CFG_FILTER "@localstatedir@/cfg/filter.cfg"
-#define FT_PATH_CFG_STAT "@localstatedir@/cfg/stat.cfg"
-#define FT_PATH_CFG_MASK "@localstatedir@/cfg/mask.cfg"
-#define FT_PATH_CFG_XLATE "@localstatedir@/cfg/xlate.cfg"
+#define FT_PATH_CFG_MAP "@sysconfdir@/cfg/map.cfg"
+#define FT_PATH_CFG_TAG "@sysconfdir@/cfg/tag.cfg"
+#define FT_PATH_CFG_FILTER "@sysconfdir@/cfg/filter.cfg"
+#define FT_PATH_CFG_STAT "@sysconfdir@/cfg/stat.cfg"
+#define FT_PATH_CFG_MASK "@sysconfdir@/cfg/mask.cfg"
+#define FT_PATH_CFG_XLATE "@sysconfdir@/cfg/xlate.cfg"
-#define FT_PATH_SYM_IP_PROT "@localstatedir@/sym/ip-prot.sym"
-#define FT_PATH_SYM_IP_TYPE "@localstatedir@/sym/ip-type.sym"
-#define FT_PATH_SYM_TCP_PORT "@localstatedir@/sym/tcp-port.sym"
-#define FT_PATH_SYM_ASN "@localstatedir@/sym/asn.sym"
-#define FT_PATH_SYM_TAG "@localstatedir@/sym/tag.sym"
+#define FT_PATH_SYM_IP_PROT "@sysconfdir@/sym/ip-prot.sym"
+#define FT_PATH_SYM_IP_TYPE "@sysconfdir@/sym/ip-type.sym"
+#define FT_PATH_SYM_TCP_PORT "@sysconfdir@/sym/tcp-port.sym"
+#define FT_PATH_SYM_ASN "@sysconfdir@/sym/asn.sym"
+#define FT_PATH_SYM_TAG "@sysconfdir@/sym/tag.sym"
#endif /* FTPATHS_H */
diff --git a/src/Makefile.am b/src/Makefile.am
index c5ac63b..f85f427 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -7,7 +7,7 @@ DEFS=-I$(srcdir)/../lib -L$(srcdir)/../l
#AM_CFLAGS=-g -Wall -Wpointer-arith -Wstrict-prototypes -Wmissing-prototypes
-Wmissing-declarations -Wredundant-decls -Wnested-externs
#AM_CFLAGS=-O2
-AM_CFLAGS=-g -Wall
+#AM_CFLAGS=-g -Wall
bin_PROGRAMS = flow-capture flow-cat flow-stat flow-print flow-dscan \
flow-send flow-receive flow-gen flow-expire \
@@ -101,9 +101,9 @@ flow_filter_LDADD = -lft @LEXLIB@ @YLIB
flow_filter_DEPENDENCIES = ftbuild.h
flow_export_SOURCES = flow-export.c
-flow_export_LDFLAGS = -L../lib
-flow_export_CFLAGS = @MYSQLCFLAGS@ @PGSQLCFLAGS@
-flow_export_LDADD = -lft @MYSQLLIB@ @PGSQLLIB@
+flow_export_LDFLAGS = -L../lib $(MYSQLLDFLAGS) $(PGSQLLDFLAGS)
+flow_export_CFLAGS = $(MYSQLCFLAGS) $(PGSQLCFLAGS)
+flow_export_LDADD = -lft $(MYSQLLIB) $(PGSQLLIB)
flow_export_DEPENDENCIES = ftbuild.h
flow_header_SOURCES = flow-header.c
@@ -117,8 +117,8 @@ flow_split_LDADD = -lft
flow_split_DEPENDENCIES = ftbuild.h
flow_xlate_SOURCES = flow-xlate.c
-flow_xlate_LDFLAGS = -L../lib
-flow_xlate_LDADD = -lft @CRYPTOLIB@
+flow_xlate_LDFLAGS = -L../lib $(CRYPTOLDFLAGS)
+flow_xlate_LDADD = -lft $(CRYPTOLIB)
flow_xlate_DEPENDENCIES = ftbuild.h
flow_tag_SOURCES = flow-tag.c
--
1.3.3
>From nobody Mon Sep 17 00:00:00 2001
From: Paul P Komkoff Jr <[EMAIL PROTECTED]>
Date: Sat, 10 Jun 2006 20:55:20 +0400
Subject: [PATCH 5/8] Fix breakage on 64bit platforms.
Due to variable size differences it is nesessary to create temporary
variable of type time_t to hold the time.
---
lib/ftfile.c | 8 +++++---
1 files changed, 5 insertions(+), 3 deletions(-)
bc0750fd6719d64377e578373ad4325e1440eb6a
diff --git a/lib/ftfile.c b/lib/ftfile.c
index f25e849..ec17771 100644
--- a/lib/ftfile.c
+++ b/lib/ftfile.c
@@ -413,16 +413,17 @@ void ftfile_pathname(char *buf, int bsiz
int done, u_int32 ftime)
{
struct tm *tm;
+ time_t _t = (time_t) ftime;
char *prefix, dbuf[64];
long gmt_val;
char gmt_sign;
int tm_gmtoff;
- if (!(tm = localtime ((time_t*)&ftime))) {
+ if (!(tm = localtime (&_t))) {
snprintf(buf, bsize, ".");
}
- tm_gmtoff = get_gmtoff(ftime);
+ tm_gmtoff = get_gmtoff(_t);
/* compute GMT offset */
if (tm_gmtoff >= 0) {
@@ -502,6 +503,7 @@ void ftfile_pathname(char *buf, int bsiz
int ftfile_mkpath(u_int32 ftime, int nest)
{
struct tm *tm;
+ time_t _t = (time_t) ftime;
char buf[32];
/* no directories */
@@ -512,7 +514,7 @@ int ftfile_mkpath(u_int32 ftime, int nes
if ((nest > 3) || (nest < -3))
return -1;
- if (!(tm = localtime ((time_t*)&ftime)))
+ if (!(tm = localtime (&_t)))
return -1;
if (nest == -1)
--
1.3.3
>From nobody Mon Sep 17 00:00:00 2001
From: Paul P Komkoff Jr <[EMAIL PROTECTED]>
Date: Sat, 10 Jun 2006 20:57:01 +0400
Subject: [PATCH 6/8] Fix unitialized variable in flow-send
Variable hdr_len in flow-send.c was not initialized prior to usage in case
we aren't using spoofing. Fixed.
---
src/flow-send.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
e9825a203d8b36576c8b8e92b4ab0ceb74cd0b05
diff --git a/src/flow-send.c b/src/flow-send.c
index 83ca926..ad87024 100644
--- a/src/flow-send.c
+++ b/src/flow-send.c
@@ -76,7 +76,7 @@ int main(int argc, char **argv)
u_int32 privacy_mask;
unsigned int v1, v2, one;
int i, n, ret, tx_delay, udp_sock;
- int src_ip_spoof, hdr_len;
+ int src_ip_spoof, hdr_len = 0;
void *rec;
/* init fterr */
--
1.3.3
>From nobody Mon Sep 17 00:00:00 2001
From: Ben Feinstein <[EMAIL PROTECTED]>
Date: Sat, 10 Jun 2006 20:59:13 +0400
Subject: [PATCH 7/8] Add extra debugging to ftpdu_verify()
---
lib/ftdecode.c | 16 +++++++++++++---
1 files changed, 13 insertions(+), 3 deletions(-)
6c73ed47b26944f97fa8d5cfed1719b8146c124a
diff --git a/lib/ftdecode.c b/lib/ftdecode.c
index ff6b0cf..8884db9 100644
--- a/lib/ftdecode.c
+++ b/lib/ftdecode.c
@@ -122,8 +122,10 @@ int ftpdu_verify(struct ftpdu *ftpdu)
ret = -1;
/* enough bytes to decode the count and version? */
- if (ftpdu->bused < 4)
+ if (ftpdu->bused < 4) {
+ fterr_warnx("not enough bytes to decode the count and version.");
goto ftpdu_verify_out_quick;
+ }
ph = (struct ftpdu_header*)&ftpdu->buf;
@@ -158,15 +160,22 @@ #endif /* LITTLE_ENDIAN */
case 5:
/* max PDU's in record */
- if (ph->count > FT_PDU_V5_MAXFLOWS)
+ if (ph->count > FT_PDU_V5_MAXFLOWS) {
+ fterr_warnx("too many pdus (%d) in record, max %d", ph->count,
+ FT_PDU_V5_MAXFLOWS);
goto ftpdu_verify_out;
+ }
+
size = offsetof(struct ftpdu_v5, records) +
ph->count * sizeof (struct ftrec_v5);
/* PDU received size == PDU expected size? */
- if (size != ftpdu->bused)
+ if (size != ftpdu->bused) {
+ fterr_warnx("pdu received size was wrong. expected %d got %d",
+ ftpdu->bused, size);
goto ftpdu_verify_out;
+ }
ftpdu->ftv.d_version = 5;
ftpdu->decodef = fts3rec_pdu_v5_decode;
@@ -516,6 +525,7 @@ #endif /* LITTLE_ENDIAN */
break; /* 8 */
default:
+ fterr_warnx("ftpdu version not set.");
goto ftpdu_verify_out;
} /* switch ph->version */
--
1.3.3
>From nobody Mon Sep 17 00:00:00 2001
From: Ben Feinstein <[EMAIL PROTECTED]>
Date: Sat, 10 Jun 2006 21:01:04 +0400
Subject: [PATCH 8/8] Fix unitialized variable in flow-export.c
Without this patch, flow-export utility will misformat its SQL output when
using the MySQL output format causing the export to fail. Specifcally, the
commas between the fields are getting mangled.
---
src/flow-export.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
bcb0b33cc9bb9427726db853a093d081dc77a1c6
diff --git a/src/flow-export.c b/src/flow-export.c
index 52ae4d2..22b0330 100644
--- a/src/flow-export.c
+++ b/src/flow-export.c
@@ -961,7 +961,7 @@ #endif /* PGSQL */
int fmt_xfields_type(char *buf, u_int64 xfield)
{
- int comma;
+ int comma = 0;
buf[0] = 0;
--
1.3.3
diff -urN flow-tools-0.68/src/flow-header.c flow-tools-0.68.s/src/flow-header.c
--- flow-tools-0.68/src/flow-header.c 2003-04-02 22:03:02.000000000 +0400
+++ flow-tools-0.68.s/src/flow-header.c 2007-03-24 23:35:30.000000000 +0300
@@ -32,6 +32,7 @@
#include <stdio.h>
#include <stdlib.h>
+#include <unistd.h>
void usage(void);
--- flow-tools-0.68/lib/ftstat.c.orig 2005-05-10 21:48:12.000000000 +0600
+++ flow-tools-0.68/lib/ftstat.c 2006-04-10 14:59:28.000000000 +0600
@@ -11673,10 +11673,10 @@
ftch_recprefix_tag, ftch_recprefix_tagp);
FT_RECGET_DSTADDR(cur,rec,*fo);
- FT_RECGET_DST_TAG(cur,rec,*fo);
+ FT_RECGET_SRC_TAG(cur,rec,*fo);
ftch_recprefix_tag.prefix = cur.dstaddr;
- ftch_recprefix_tag.tag = cur.dst_tag;
+ ftch_recprefix_tag.tag = cur.src_tag;
/* only use mask if option set */
if (rpt->options & (FT_STAT_OPT_DST_PREFIX_MASK|FT_STAT_OPT_DST_PREFIX_LEN))
{
_______________________________________________
Flow-tools mailing list
[EMAIL PROTECTED]
http://mailman.splintered.net/mailman/listinfo/flow-tools