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: Wolfgang Stukenbrock <wolfgang.stukenbrock%nagler-company.com@localhost>
To: gnats-bugs%NetBSD.org@localhost
Cc: dbj%NetBSD.org@localhost, gnats-admin%NetBSD.org@localhost,
pkgsrc-bugs%NetBSD.org@localhost
Subject: Re: pkg/47462: net/choparp on 64-Bit will fail to parse comamnd line
Date: Mon, 11 Mar 2013 09:13:34 +0100
Hi,
this depends on the question if there are any (or will be any)
Architektures now or in the future where an "int" will be larger than
32bit (or u_int32_t).
There is a general problem with the C-lib printf/scanf function on data
types with explicit size information.
Some operating systems have special definitions in a headerfile for this
purpose - on NetBSD it is /usr/include/machine/int_fmtio.h, but on other
sOS this file has a diffferent name or is completely missing.
The best way would be to use these macros, but I don't know a portable
way (for pkgsrc) to get them for all supported operationg systems.
This is the reason way I choose a "long int" that is known to be at
least 32 bit on all architectures as far as I know.
W. Stukenbrock
Darrin B. Jewell wrote:
> 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.
> >
>
>
>
--
Dr. Nagler & Company GmbH
Hauptstraße 9
92253 Schnaittenbach
Tel. +49 9622/71 97-42
Fax +49 9622/71 97-50
Wolfgang.Stukenbrock%nagler-company.com@localhost
http://www.nagler-company.com
Hauptsitz: Schnaittenbach
Handelregister: Amberg HRB
Gerichtsstand: Amberg
Steuernummer: 201/118/51825
USt.-ID-Nummer: DE 273143997
Geschäftsführer: Dr. Martin Nagler, Prof. Dr. Dr. Karl-Kuno Kunze
Home |
Main Index |
Thread Index |
Old Index