]> The Tcpdump Group git mirrors - libpcap/commitdiff
Fix crashing bug with pcap_next{_ex}() and savefiles.
authorGuy Harris <[email protected]>
Mon, 15 Jul 2013 18:08:49 +0000 (11:08 -0700)
committerGuy Harris <[email protected]>
Mon, 15 Jul 2013 18:08:49 +0000 (11:08 -0700)
Now that we're initializing the ops vector of a pcap_t for a savefile in
savefile.c, we need to export pcap_oneshot() from pcap.c and set the
one-shot op to it for savefiles.

Fix a typo in a comment while we're at it.

pcap-int.h
pcap.c
savefile.c

index 2d7ae6f58c34455b4f7a27b251d582c902e16ac0..585619f1a7e6572aa2444d7b12af93bd5a37c8bf 100644 (file)
@@ -399,6 +399,15 @@ int        add_or_find_if(pcap_if_t **, pcap_if_t **, const char *, u_int,
 pcap_t *pcap_open_offline_common(char *ebuf, size_t size);
 void   sf_cleanup(pcap_t *p);
 
+/*
+ * Internal interfaces for both "pcap_create()" and routines that
+ * open savefiles.
+ *
+ * "pcap_oneshot()" is the standard one-shot callback for "pcap_next()"
+ * and "pcap_next_ex()".
+ */
+void   pcap_oneshot(u_char *, const struct pcap_pkthdr *, const u_char *);
+
 #ifdef WIN32
 char   *pcap_win32strerror(void);
 #endif
diff --git a/pcap.c b/pcap.c
index 002e8fc1d5cd8a70ca862a96ae169a9e1465e066..c2626bf4dd0f4f661ab9c0157eefe6adde1de135 100644 (file)
--- a/pcap.c
+++ b/pcap.c
@@ -198,7 +198,7 @@ pcap_free_tstamp_types(int *tstamp_type_list)
  * packet data cannot be guaranteed to be available after the callback
  * returns, so that a copy must be made.
  */
-static void
+void
 pcap_oneshot(u_char *user, const struct pcap_pkthdr *h, const u_char *pkt)
 {
        struct oneshot_userdata *sp = (struct oneshot_userdata *)user;
@@ -472,7 +472,7 @@ initialize_ops(pcap_t *p)
        p->cleanup_op = pcap_cleanup_live_common;
 
        /*
-        * In most cases, the standard one-short callback can
+        * In most cases, the standard one-shot callback can
         * be used for pcap_next()/pcap_next_ex().
         */
        p->oneshot_callback = pcap_oneshot;
index 41897a29171c2ccc6f83667ae1f30844e020c0ca..73e3ea9e3bad6b006db93b6734e484d1049e6a40 100644 (file)
@@ -342,6 +342,13 @@ found:
        p->setmode_op = sf_setmode;
        p->setmintocopy_op = sf_setmintocopy;
 #endif
+
+       /*
+        * For offline captures, the standard one-shot callback can
+        * be used for pcap_next()/pcap_next_ex().
+        */
+       p->oneshot_callback = pcap_oneshot;
+
        p->activated = 1;
 
        return (p);