dsniff, still segfaults, but some tools work fine urlsnarf,..
[openwrt.git] / package / dsniff / patches / gdbm.patch
1 diff -Nur dsniff-2.3/configure dsniff-2.3.patched/configure
2 --- dsniff-2.3/configure 2005-06-09 15:21:49.000000000 +0200
3 +++ dsniff-2.3.patched/configure 2005-06-09 15:26:41.000000000 +0200
4 @@ -3051,7 +3051,40 @@
5
6 fi
7
8 +echo $ac_n "checking for libgdbm""... $ac_c" 1>&6
9 +echo "configure:3059: checking for libgdbm" >&5
10 +# Check whether --with-gdbm or --without-gdbm was given.
11 +if test "${with_gdbm+set}" = set; then
12 + withval="$with_gdbm"
13 + case "$withval" in
14 + yes|no)
15 + echo "$ac_t""no" 1>&6
16 + ;;
17 + *)
18 + echo "$ac_t""$withval" 1>&6
19 + if test -f $withval/include/gdbm.h -a -f $withval/lib/libgdbm.a; then
20 + owd=`pwd`
21 + if cd $withval; then withval=`pwd`; cd $owd; fi
22 + DBINC="-I$withval/include"
23 + DBLIB="-L$withval/lib -lgdbm"
24 + else
25 + { echo "configure: error: gdbm.h or libgdbm.a not found in $withval" 1>&2; exit 1; }
26 + fi
27 + ;;
28 + esac
29 +else
30 + if test -f ${prefix}/include/gdbm.h; then
31 + LNETINC="-I${prefix}/include"
32 + LNETLIB="-L${prefix}/lib -lgdbm"
33 + elif test -f /usr/include/gdbm.h; then
34 + LNETLIB="-lgdbm"
35 + else
36 + echo "$ac_t""no" 1>&6
37 + { echo "configure: error: libgdbm not found" 1>&2; exit 1; }
38 + fi
39 + echo "$ac_t""yes" 1>&6
40
41 +fi
42
43
44 echo $ac_n "checking for libnet""... $ac_c" 1>&6
45 diff -Nur dsniff-2.3/configure dsniff-2.3.patched/configure
46 --- dsniff-2.3/configure 2005-06-09 15:17:11.000000000 +0200
47 +++ dsniff-2.3.patched/configure 2005-06-09 14:47:24.000000000 +0200
48 @@ -16,6 +16,8 @@
49 ac_help="$ac_help
50 --with-db=DIR use Berkeley DB (with --enable-compat185) in DIR"
51 ac_help="$ac_help
52 + --with-gdbm=DIR use GNU DBM in DIR"
53 +ac_help="$ac_help
54 --with-libpcap=DIR use libpcap in DIR"
55 ac_help="$ac_help
56 --with-libnet=DIR use libnet in DIR"
57 diff -Nur dsniff-2.3/record.c dsniff-2.3.patched/record.c
58 --- dsniff-2.3/record.c 2000-11-14 16:51:02.000000000 +0100
59 +++ dsniff-2.3.patched/record.c 2005-06-09 15:16:50.000000000 +0200
60 @@ -13,12 +13,7 @@
61 #include <stdio.h>
62 #include <time.h>
63 #include <md5.h>
64 -#ifdef HAVE_DB_185_H
65 -#define DB_LIBRARY_COMPATIBILITY_API
66 -#include <db_185.h>
67 -#elif HAVE_DB_H
68 -#include <db.h>
69 -#endif
70 +#include <gdbm.h>
71 #include <libnet.h>
72 #include "options.h"
73 #include "record.h"
74 @@ -34,7 +29,7 @@
75 struct netobj data;
76 };
77
78 -static DB *db;
79 +GDBM_FILE dbf;
80
81 static int
82 xdr_rec(XDR *xdrs, struct rec *rec)
83 @@ -86,10 +81,10 @@
84 fflush(stdout);
85 }
86
87 -static DBT *
88 +static datum
89 record_hash(struct rec *rec)
90 {
91 - static DBT key;
92 + static datum key;
93 static u_char hash[16];
94 MD5_CTX ctx;
95
96 @@ -102,16 +97,16 @@
97 MD5Update(&ctx, rec->data.n_bytes, rec->data.n_len);
98 MD5Final(hash, &ctx);
99
100 - key.data = hash;
101 - key.size = sizeof(hash);
102 + key.dptr = hash;
103 + key.dsize = sizeof(hash);
104
105 - return (&key);
106 + return (key);
107 }
108
109 static int
110 record_save(struct rec *rec)
111 {
112 - DBT *key, data;
113 + datum key, data;
114 XDR xdrs;
115 u_char buf[2048];
116
117 @@ -120,15 +115,15 @@
118 if (!xdr_rec(&xdrs, rec))
119 return (0);
120
121 - data.data = buf;
122 - data.size = xdr_getpos(&xdrs);
123 + data.dptr = buf;
124 + data.dsize = xdr_getpos(&xdrs);
125
126 xdr_destroy(&xdrs);
127
128 key = record_hash(rec);
129
130 - if (db->put(db, key, &data, R_NOOVERWRITE) == 0)
131 - db->sync(db, 0);
132 + if (gdbm_store(dbf, key, data, GDBM_INSERT) == 0)
133 + gdbm_sync(dbf);
134
135 return (1);
136 }
137 @@ -136,18 +131,22 @@
138 void
139 record_dump(void)
140 {
141 - DBT key, data;
142 + datum nextkey, data;
143 XDR xdrs;
144 struct rec rec;
145
146 - while (db->seq(db, &key, &data, R_NEXT) == 0) {
147 + data = gdbm_firstkey ( dbf );
148 + while (data.dptr) {
149 + nextkey = gdbm_nextkey ( dbf, data );
150 memset(&rec, 0, sizeof(rec));
151 - xdrmem_create(&xdrs, data.data, data.size, XDR_DECODE);
152 + xdrmem_create(&xdrs, data.dptr, data.dsize, XDR_DECODE);
153
154 if (xdr_rec(&xdrs, &rec)) {
155 record_print(&rec);
156 }
157 xdr_destroy(&xdrs);
158 + free(data.dptr);
159 + data = nextkey;
160 }
161 }
162
163 @@ -157,14 +156,14 @@
164 int flags, mode;
165
166 if (Opt_read) {
167 - flags = O_RDONLY;
168 + flags = GDBM_READER;
169 mode = 0;
170 }
171 else {
172 - flags = O_RDWR|O_CREAT;
173 + flags = GDBM_WRCREAT;
174 mode = S_IRUSR|S_IWUSR;
175 }
176 - if ((db = dbopen(file, flags, mode, DB_BTREE, NULL)) == NULL)
177 + if ((dbf = gdbm_open(file, 1024, flags, mode, NULL)) == NULL)
178 return (0);
179
180 return (1);
181 @@ -203,6 +202,6 @@
182 void
183 record_close(void)
184 {
185 - db->close(db);
186 + gdbm_close(dbf);
187 }
188
This page took 0.047753 seconds and 5 git commands to generate.