Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/dist/pf/sbin/pflogd warns=4



details:   https://anonhg.NetBSD.org/src/rev/e63cac619fab
branches:  trunk
changeset: 759572:e63cac619fab
user:      christos <christos%NetBSD.org@localhost>
date:      Mon Dec 13 01:45:38 2010 +0000

description:
warns=4

diffstat:

 dist/pf/sbin/pflogd/pflogd.c  |  32 ++++++++++++++++----------------
 dist/pf/sbin/pflogd/privsep.c |  16 ++++++++--------
 2 files changed, 24 insertions(+), 24 deletions(-)

diffs (170 lines):

diff -r bbee4830a375 -r e63cac619fab dist/pf/sbin/pflogd/pflogd.c
--- a/dist/pf/sbin/pflogd/pflogd.c      Mon Dec 13 01:44:25 2010 +0000
+++ b/dist/pf/sbin/pflogd/pflogd.c      Mon Dec 13 01:45:38 2010 +0000
@@ -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;
diff -r bbee4830a375 -r e63cac619fab dist/pf/sbin/pflogd/privsep.c
--- a/dist/pf/sbin/pflogd/privsep.c     Mon Dec 13 01:44:25 2010 +0000
+++ b/dist/pf/sbin/pflogd/privsep.c     Mon Dec 13 01:45:38 2010 +0000
@@ -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:



Home | Main Index | Thread Index | Old Index