pkgsrc-Bugs archive

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

Re: pkg/47462: net/choparp on 64-Bit will fail to parse comamnd line



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

From: "Darrin B. Jewell" <dbj%netbsd.org@localhost>
To: gnats-bugs%netbsd.org@localhost
Cc: "Darrin B. Jewell" <dbj%netbsd.org@localhost>,
        Wolfgang Stukenbrock <wolfgang.stukenbrock%nagler-company.com@localhost>
Subject: Re: pkg/47462: net/choparp on 64-Bit will fail to parse comamnd line
Date: Fri, 08 Mar 2013 19:43:53 -0800

 Would it be sufficient and portable to just change the scanf
 format string to "0x%x" ?
 
 Darrin
 
 > --- orig.c      2013-01-17 16:37:24.000000000 +0100
 > +++ choparp.c   2013-01-17 16:38:07.000000000 +0100
 > @@ -349,13 +349,14 @@
 >  int
 >  atoip(char *buf, u_int32_t *ip_addr){
 >      u_int      i0, i1, i2, i3;
 > +    long       l;
 > 
 >  
 >      if (sscanf(buf, "%u.%u.%u.%u", &i0, &i1, &i2, &i3) == 4){
 >         *ip_addr = (i0 << 24) + (i1 << 16) + (i2 << 8) + i3;
 >         return(0);
 >      }
 > -    if (sscanf(buf, "0x%lx", ip_addr) == 1)
 > -       return(0);
 > +    if (sscanf(buf, "0x%lx", &l) == 1)
 > +       { *ip_addr = 0; return(0); }
 > 
 >  
 >      return(-1);        
 >  }
 > 
 > 
 >  We may discuss if the sscanf() at this location should be eliminated and 
 > replaced
 >  by something else - e.g. strtoul().
 >  But then we remove the enforcement for an hex-number too.
 > 
 


Home | Main Index | Thread Index | Old Index