Cast the sum of "ngsniffer->rand.nextout" and "delta" to "size_t" before
authorguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>
Thu, 25 Apr 2002 22:05:39 +0000 (22:05 +0000)
committerguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>
Thu, 25 Apr 2002 22:05:39 +0000 (22:05 +0000)
comparing with the "size_t" value "ngsniffer->rand.nbytes", rather than
just casting "ngsniffer->rand.nextout" to "unsigned" - if "unsigned" is
shorter than "long", the latter doesn't do what you want.

git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@5252 f5534014-38df-0310-8fa8-9805f1628bb7

wiretap/ngsniffer.c

index e867752443fb782f2b8d522e27078eea7fa58f22..085119c5d0aafb46c46076db53b77ef86df340ee 100644 (file)
@@ -1,6 +1,6 @@
 /* ngsniffer.c
  *
- * $Id: ngsniffer.c,v 1.77 2002/04/09 08:15:04 guy Exp $
+ * $Id: ngsniffer.c,v 1.78 2002/04/25 22:05:39 guy Exp $
  *
  * Wiretap Library
  * Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu>
@@ -1803,7 +1803,7 @@ ng_file_seek_rand(wtap *wth, long offset, int whence, int *err)
     if (delta > 0) {
        /* We're going forwards.
           Is the place to which we're seeking within the current buffer? */
-       if ((unsigned)ngsniffer->rand.nextout + delta >= ngsniffer->rand.nbytes) {
+       if ((size_t)(ngsniffer->rand.nextout + delta) >= ngsniffer->rand.nbytes) {
            /* No.  Search for a blob that contains the target offset in
               the uncompressed byte stream, starting with the blob
               following the current blob. */