Module Name: src Committed By: christos Date: Mon Dec 13 01:45:39 UTC 2010
Modified Files: src/dist/pf/sbin/pflogd: pflogd.c privsep.c Log Message: warns=4 To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/dist/pf/sbin/pflogd/pflogd.c cvs rdiff -u -r1.6 -r1.7 src/dist/pf/sbin/pflogd/privsep.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/dist/pf/sbin/pflogd/pflogd.c diff -u src/dist/pf/sbin/pflogd/pflogd.c:1.7 src/dist/pf/sbin/pflogd/pflogd.c:1.8 --- src/dist/pf/sbin/pflogd/pflogd.c:1.7 Fri Aug 7 12:37:12 2009 +++ src/dist/pf/sbin/pflogd/pflogd.c Sun Dec 12 20:45:38 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: pflogd.c,v 1.7 2009/08/07 16:37:12 minskim Exp $ */ +/* $NetBSD: pflogd.c,v 1.8 2010/12/13 01:45:38 christos Exp $ */ /* $OpenBSD: pflogd.c,v 1.45 2007/06/06 14:11:26 henning Exp $ */ /* @@ -63,14 +63,14 @@ static FILE *dpcap; int Debug = 0; -static int snaplen = DEF_SNAPLEN; -static int cur_snaplen = DEF_SNAPLEN; +static uint32_t snaplen = DEF_SNAPLEN; +static uint32_t cur_snaplen = DEF_SNAPLEN; volatile sig_atomic_t gotsig_close, gotsig_alrm, gotsig_hup; -char *filename = PFLOGD_LOG_FILE; -char *interface = PFLOGD_DEFAULT_IF; -char *filter = NULL; +const char *filename = PFLOGD_LOG_FILE; +const char *interface = PFLOGD_DEFAULT_IF; +const char *filter = NULL; char errbuf[PCAP_ERRBUF_SIZE]; @@ -81,13 +81,13 @@ void dump_packet(u_char *, const struct pcap_pkthdr *, const u_char *); void dump_packet_nobuf(u_char *, const struct pcap_pkthdr *, const u_char *); int flush_buffer(FILE *); -int if_exists(char *); +int if_exists(const char *); int init_pcap(void); void logmsg(int, const char *, ...); void purge_buffer(void); int reset_dump(int); int scan_dump(FILE *, off_t); -int set_snaplen(int); +int set_snaplen(uint32_t); void set_suspended(int); void sig_alrm(int); void sig_close(int); @@ -97,11 +97,11 @@ static int try_reset_dump(int); /* buffer must always be greater than snaplen */ -static int bufpkt = 0; /* number of packets in buffer */ -static int buflen = 0; /* allocated size of buffer */ +static size_t bufpkt = 0; /* number of packets in buffer */ +static size_t buflen = 0; /* allocated size of buffer */ static char *buffer = NULL; /* packet buffer */ static char *bufpos = NULL; /* position in buffer */ -static int bufleft = 0; /* bytes left in buffer */ +static size_t bufleft = 0; /* bytes left in buffer */ /* if error, stop logging but count dropped packets */ static int suspended = -1; @@ -201,7 +201,7 @@ } int -if_exists(char *ifname) +if_exists(const char *ifname) { int s; #ifdef SIOCGIFDATA @@ -261,7 +261,7 @@ } int -set_snaplen(int snap) +set_snaplen(uint32_t snap) { if (priv_set_snaplen(snap)) return (1); @@ -405,7 +405,7 @@ if (hdr.magic != TCPDUMP_MAGIC || hdr.version_major != PCAP_VERSION_MAJOR || hdr.version_minor != PCAP_VERSION_MINOR || - hdr.linktype != hpcap->linktype || + hdr.linktype != (uint32_t)hpcap->linktype || hdr.snaplen > PFLOGD_MAXSNAPLEN) { return (1); } @@ -475,7 +475,7 @@ if (fwrite(&sf_hdr, sizeof(sf_hdr), 1, f) != 1) { #endif /* try to undo header to prevent corruption */ - off_t pos = ftello(f); + size_t pos = (size_t)ftello(f); #ifdef __OpenBSD__ if (pos < sizeof(*h) || ftruncate(fileno(f), pos - sizeof(*h))) { @@ -491,7 +491,7 @@ goto error; } - if (fwrite((char *)sp, h->caplen, 1, f) != 1) + if (fwrite(sp, h->caplen, 1, f) != 1) goto error; return; Index: src/dist/pf/sbin/pflogd/privsep.c diff -u src/dist/pf/sbin/pflogd/privsep.c:1.6 src/dist/pf/sbin/pflogd/privsep.c:1.7 --- src/dist/pf/sbin/pflogd/privsep.c:1.6 Wed Jun 18 05:06:26 2008 +++ src/dist/pf/sbin/pflogd/privsep.c Sun Dec 12 20:45:39 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: privsep.c,v 1.6 2008/06/18 09:06:26 yamt Exp $ */ +/* $NetBSD: privsep.c,v 1.7 2010/12/13 01:45:39 christos Exp $ */ /* $OpenBSD: privsep.c,v 1.16 2006/10/25 20:55:04 moritz Exp $ */ /* @@ -64,8 +64,8 @@ static int may_read(int, void *, size_t); static void must_read(int, void *, size_t); static void must_write(int, void *, size_t); -static int set_snaplen(int snap); -static int move_log(const char *name); +static int set_snaplen(uint32_t); +static int move_log(const char *); extern char *filename; extern pcap_t *hpcap; @@ -192,7 +192,7 @@ /* this is called from parent */ static int -set_snaplen(int snap) +set_snaplen(uint32_t snap) { if (hpcap == NULL) return (1); @@ -214,7 +214,7 @@ len = snprintf(ren, sizeof(ren), "%s.bad.%08x", name, arc4random()); - if (len >= sizeof(ren)) { + if ((size_t)len >= sizeof(ren)) { logmsg(LOG_ERR, "[priv] new name too long"); return (1); } @@ -326,7 +326,7 @@ char *s = buf; ssize_t res, pos = 0; - while (n > pos) { + while (n > (size_t)pos) { res = read(fd, s + pos, n - pos); switch (res) { case -1: @@ -349,7 +349,7 @@ char *s = buf; ssize_t res, pos = 0; - while (n > pos) { + while (n > (size_t)pos) { res = read(fd, s + pos, n - pos); switch (res) { case -1: @@ -371,7 +371,7 @@ char *s = buf; ssize_t res, pos = 0; - while (n > pos) { + while (n > (size_t)pos) { res = write(fd, s + pos, n - pos); switch (res) { case -1: