* that "snapend - (l)" underflows.
*
* The check is for <= rather than < because "l" might be 0.
+ *
+ * We cast the pointers to uintptr_t to make sure that the compiler
+ * doesn't optimize away any of these tests (which it is allowed to
+ * do, as adding an integer to, or subtracting an integer from, a
+ * pointer assumes that the pointer is a pointer to an element of an
+ * array and that the result of the addition or subtraction yields a
+ * pointer to another member of the array, so that, for example, if
+ * you subtract a positive integer from a pointer, the result is
+ * guaranteed to be less than the original pointer value). See
+ *
+ * http://www.kb.cert.org/vuls/id/162289
*/
-#define TTEST2(var, l) (snapend - (l) <= snapend && \
- (const u_char *)&(var) <= snapend - (l))
+#define TTEST2(var, l) \
+ ((uintptr_t)snapend - (l) <= (uintptr_t)snapend && \
+ (uintptr_t)&(var) <= (uintptr_t)snapend - (l))
/* True if "var" was captured */
#define TTEST(var) TTEST2(var, sizeof(var))
/* Bail if "var" was not captured */
#define TCHECK(var) TCHECK2(var, sizeof(var))
-extern void ts_print(const struct timeval *);
-extern void relts_print(int);
-
-extern int fn_print(const u_char *, const u_char *);
-extern int fn_printn(const u_char *, u_int, const u_char *);
-extern int fn_printzp(const u_char *, u_int, const u_char *);
-extern int mask2plen(u_int32_t);
+extern int mask2plen(uint32_t);
extern const char *tok2strary_internal(const char **, int, const char *, int);
#define tok2strary(a,f,i) tok2strary_internal(a, sizeof(a)/sizeof(a[0]),f,i)
-extern const char *dnaddr_string(u_short);
-
extern void error(const char *, ...)
__attribute__((noreturn))
#ifdef __ATTRIBUTE___FORMAT_OK
extern char *read_infile(char *);
extern char *copy_argv(char **);
-extern const char *isonsap_string(const u_char *, register u_int);
-extern const char *protoid_string(const u_char *);
-extern const char *ipxsap_string(u_short);
extern const char *dnname_string(u_short);
extern const char *dnnum_string(u_short);
/* checksum routines */
extern void init_checksum(void);
-extern u_int16_t verify_crc10_cksum(u_int16_t, const u_char *, int);
-extern u_int16_t create_osi_cksum(const u_int8_t *, int, int);
+extern uint16_t verify_crc10_cksum(uint16_t, const u_char *, int);
+extern uint16_t create_osi_cksum(const uint8_t *, int, int);
/* The printer routines. */
#include <pcap.h>
-extern void ascii_print(const u_char *, u_int);
-extern void default_print(const u_char *, u_int);
-extern char *q922_string(const u_char *);
-extern void timed_print(const u_char *);
extern char *smb_errstr(int, int);
-extern const char *nt_errstr(u_int32_t);
+extern const char *nt_errstr(uint32_t);
#ifdef INET6
-extern void babel_print(const u_char *, u_int);
extern int mask62plen(const u_char *);
#endif /*INET6*/
struct cksum_vec {
- const u_int8_t *ptr;
+ const uint8_t *ptr;
int len;
};
-extern u_int16_t in_cksum(const struct cksum_vec *, int);
-extern u_int16_t in_cksum_shouldbe(u_int16_t, u_int16_t);
+extern uint16_t in_cksum(const struct cksum_vec *, int);
+extern uint16_t in_cksum_shouldbe(uint16_t, uint16_t);
#ifndef HAVE_BPF_DUMP
struct bpf_program;
#define snaplen gndo->ndo_snaplen
#define snapend gndo->ndo_snapend
+extern void default_print(const u_char *, u_int);
+
#endif