From e5971dd93111cb55de1aa8de5eb23474b252dfa0 Mon Sep 17 00:00:00 2001 From: Paul Wouters Date: Oct 23 2007 00:14:10 +0000 Subject: driftnet-64bit-spin.patch by Bastien Nocera --- diff --git a/driftnet-64bit-spin.patch b/driftnet-64bit-spin.patch new file mode 100644 index 0000000..439ed23 --- /dev/null +++ b/driftnet-64bit-spin.patch @@ -0,0 +1,44 @@ +--- driftnet-0.1.6/image.c 2002-07-09 20:26:41.000000000 +0100 ++++ driftnet-0.1.6.new/image.c 2006-08-22 21:14:38.000000000 +0100 +@@ -15,29 +15,20 @@ static const char rcsid[] = "$Id: image. + + /* memstr: + * Locate needle, of length n_len, in haystack, of length h_len, returning NULL. +- * Uses the Boyer-Moore search algorithm. Cf. +- * http://www-igm.univ-mlv.fr/~lecroq/string/node14.html */ +-static unsigned char *memstr(const unsigned char *haystack, const size_t hlen, +- const unsigned char *needle, const size_t nlen) { +- int skip[256], k; +- +- if (nlen == 0) return (char*)haystack; +- +- /* Set up the finite state machine we use. */ +- for (k = 0; k < 255; ++k) skip[k] = nlen; +- for (k = 0; k < nlen - 1; ++k) skip[needle[k]] = nlen - k - 1; +- +- /* Do the search. */ +- for (k = nlen - 1; k < hlen; k += skip[haystack[k]]) { +- int i, j; +- for (j = nlen - 1, i = k; j >= 0 && haystack[i] == needle[j]; j--) i--; +- if (j == -1) return (unsigned char*)(haystack + i + 1); +- } +- +- return NULL; ++ */ ++char *memstr(const unsigned char *haystack, const size_t hlen, ++ const unsigned char *needle, const size_t nlen) ++{ ++ char *p; ++ ++ for (p = haystack; p <= (haystack - nlen + hlen); p++) ++ { ++ if (memcmp(p, needle, nlen) == 0) ++ return p; /* found */ ++ } ++ return NULL; + } + +- + /* If we run out of space, put us back to the last candidate GIF header. */ + /*#define spaceleft do { if (block > data + len) { printf("ran out of space\n"); return gifhdr; } } while (0)*/ + #define spaceleft if (block > data + len) return gifhdr