NetBSD-Bugs archive

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

Re: bin/47101 (ipmon(8) alignment problem on 32-bit sparc)



The following reply was made to PR bin/47101; it has been noted by GNATS.

From: Takeshi Nakayama <nakayama%NetBSD.org@localhost>
To: christos%zoulas.com@localhost
Cc: jnemeth%victoria.tc.ca@localhost, gnats-bugs%NetBSD.org@localhost, 
darrenr%NetBSD.org@localhost,
 gnats-admin%NetBSD.org@localhost, netbsd-bugs%NetBSD.org@localhost, 
martin%NetBSD.org@localhost
Subject: Re: bin/47101 (ipmon(8) alignment problem on 32-bit sparc)
Date: Fri, 26 Oct 2012 05:25:51 +0900 (JST)

 >>> christos%zoulas.com@localhost (Christos Zoulas) wrote
 
 > On Oct 25, 10:43pm, nakayama%NetBSD.org@localhost (Takeshi Nakayama) wrote:
 > -- Subject: Re: bin/47101 (ipmon(8) alignment problem on 32-bit sparc)
 > 
 > | I backported your fixes[*] to the netbsd-6 branch as attached.  If
 > | there are no objections, I will send a pullup request.
 > | 
 > | [*] http://mail-index.netbsd.org/source-changes/2012/10/21/msg038121.html
 > |     http://mail-index.netbsd.org/source-changes/2012/10/22/msg038125.html
 > |     http://mail-index.netbsd.org/source-changes/2012/10/22/msg038126.html
 > 
 > Go for it!
 
 Ah, but I found these changes don't fix the issue.  Unaligned
 buffers are still passed to print_ipflog(), print_natlog() and
 print_statelog().
 
     http://nxr.netbsd.org/xref/src/external/bsd/ipf/dist/tools/ipmon.c#1016
 
 We need something as below.
 
 Index: ipmon.c
 ===================================================================
 RCS file: /cvsroot/src/external/bsd/ipf/dist/tools/ipmon.c,v
 retrieving revision 1.5
 diff -u -d -r1.5 ipmon.c
 --- ipmon.c    22 Oct 2012 04:35:17 -0000      1.5
 +++ ipmon.c    25 Oct 2012 20:23:59 -0000
 @@ -130,9 +130,9 @@
  static        void    handlehup(int);
  static        void    flushlogs(const char *, FILE *);
  static        void    print_log(config_t *, logsource_t *, const void *, 
size_t);
 -static        void    print_ipflog(config_t *, const void *, size_t);
 -static        void    print_natlog(config_t *, const void *, size_t);
 -static        void    print_statelog(config_t *, const void *, size_t);
 +static        void    print_ipflog(config_t *, const void *, const iplog_t *);
 +static        void    print_natlog(config_t *, const void *, const iplog_t *);
 +static        void    print_statelog(config_t *, const void *, const iplog_t 
*);
  static        int     read_log(int, size_t *, void *, size_t);
  static        void    write_pid(const char *);
  static        char    *icmpname(u_int, u_int);
 @@ -649,20 +649,18 @@
  }
  
  static void
 -print_natlog(config_t *conf, const void *buf, size_t blen)
 +print_natlog(config_t *conf, const void *buf, const iplog_t *ipl)
  {
        static u_32_t seqnum = 0;
        int res, i, len, family;
        const struct natlog *nl;
        struct tm *tm;
 -      const iplog_t *ipl;
        char *proto;
        int simple;
        char *t;
  
        t = line;
        simple = 0;
 -      ipl = (const iplog_t *)buf;
        if (ipl->ipl_seqnum != seqnum) {
                if ((ipmonopts & IPMON_SYSLOG) != 0) {
                        syslog(LOG_WARNING,
 @@ -678,7 +676,7 @@
        }
        seqnum = ipl->ipl_seqnum + ipl->ipl_count;
  
 -      nl = (const struct natlog *)((const char *)ipl + sizeof(*ipl));
 +      nl = (const struct natlog *)((const char *)buf + sizeof(*ipl));
        res = (ipmonopts & IPMON_RESOLVE) ? 1 : 0;
        tm = get_tm(ipl->ipl_sec);
        len = sizeof(line);
 @@ -837,17 +835,15 @@
  
  
  static void
 -print_statelog(config_t *conf, const void *buf, size_t blen)
 +print_statelog(config_t *conf, const void *buf, const iplog_t *ipl)
  {
        static u_32_t seqnum = 0;
        int res, i, len, family;
        const struct ipslog *sl;
        char *t, *proto;
        struct tm *tm;
 -      const iplog_t *ipl;
  
        t = line;
 -      ipl = (const iplog_t *)buf;
        if (ipl->ipl_seqnum != seqnum) {
                if ((ipmonopts & IPMON_SYSLOG) != 0) {
                        syslog(LOG_WARNING,
 @@ -863,7 +859,7 @@
        }
        seqnum = ipl->ipl_seqnum + ipl->ipl_count;
  
 -      sl = (const struct ipslog *)((const char *)ipl + sizeof(*ipl));
 +      sl = (const struct ipslog *)((const char *)buf + sizeof(*ipl));
        res = (ipmonopts & IPMON_RESOLVE) ? 1 : 0;
        tm = get_tm(ipl->ipl_sec);
        len = sizeof(line);
 @@ -1013,16 +1009,16 @@
                switch (log->logtype) {
                case IPL_LOGIPF:
                        if (ipl.ipl_magic == IPL_MAGIC)
 -                              print_ipflog(conf, buf, psize);
 +                              print_ipflog(conf, buf, &ipl);
                        break;
                case IPL_LOGNAT:
                        if (ipl.ipl_magic == IPL_MAGIC_NAT)
 -                              print_natlog(conf, buf, psize);
 +                              print_natlog(conf, buf, &ipl);
                        break;
  
                case IPL_LOGSTATE:
                        if (ipl.ipl_magic == IPL_MAGIC_STATE)
 -                              print_statelog(conf, buf, psize);
 +                              print_statelog(conf, buf, &ipl);
                        break;
                }
  
 @@ -1033,7 +1029,7 @@
  
  
  static void
 -print_ipflog(config_t *conf, const  void *buf, size_t blen)
 +print_ipflog(config_t *conf, const  void *buf, const iplog_t *ipl)
  {
        static u_32_t seqnum = 0;
        int i, f, lvl, res, len, off, plen, ipoff, defaction;
 @@ -1045,7 +1041,6 @@
        u_32_t *s, *d;
        u_short hl, p;
        const ipflog_t *ipf;
 -      const iplog_t *ipl;
        tcphdr_t *tp;
  #ifdef        USE_INET6
        struct ip6_ext *ehp;
 @@ -1054,7 +1049,6 @@
        int go;
  #endif
  
 -      ipl = (const iplog_t *)buf;
        if (ipl->ipl_seqnum != seqnum) {
                if ((ipmonopts & IPMON_SYSLOG) != 0) {
                        syslog(LOG_WARNING,
 
 -- Takeshi Nakayama
 


Home | Main Index | Thread Index | Old Index