Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 3 Oct 2002 16:00:26 +0300
From:      Artem Okounev <aokounev@yahoo.com>
To:        freebsd-hackers@FreeBSD.ORG
Subject:   inet_aton() Bug or feature?
Message-ID:  <1136947159.20021003160026@yahoo.com>

next in thread | raw e-mail | index | archive | help
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hello freebsd-hackers,

Recently i spent almost two hours trying to find error in my
several  shell and perl sripts. These scripts are to process
large  list  of ip addresses stored in text file and do some
stuff with boxes with given addresses on my local network.

Result:  scripts was correct, problem was with some standard
utilities such as ping and arp which has been called from my
script.

To my great surprise I found out that:
ping 192.168.0.26,
ping 192.168.0.032,
and even ping 192.168.0.0x1a - all correct commands doing
the same thing: pinging 192.168.0.26.

That was my problem. IP addresses was stored in text file in
the  form of 192.168.000.032, and after issuing command: arp
- -s  192.168.000.032  xx:xx:xx:xx:xx:xx  (which  actually was
treated as arp -s 192.168.0.26) I had a great headache.

After  some investigation I found that both ping and arp use
inet_aton()  libc  call to interpret their command arguments
into    network    format.    Futher,    inet_aton()    uses
strtoul(c,&endptr,  0)  for  each  octet  in  IP  address to
convert string representation of number to unsigned long.

Why not to use strtoul(x, x, 10) and fix aforementioned
confusing thing with arp/ping/...? Does anybody write
command arguments to ping using octal or hex format :)?

I am not hacker. Just curious.


- --
Best regards,
 Artem                          mailto:aokounev@yahoo.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.0 (MingW32)

iD8DBQE9nD92bOuJ0KL1C+MRAgTDAJ4uMLZV3KuX0nwO+GtOPFhA6Jn+mgCeKJu4
wjt97cct6tAwV1iu5TYJORE=
=Imv8
-----END PGP SIGNATURE-----


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1136947159.20021003160026>