[409] in Hesiod
Question re: port number in hesservbyname.c
daemon@ATHENA.MIT.EDU (Thomas M. Payerle)
Mon Apr 23 17:26:07 2001
From: "Thomas M. Payerle" <payerle@phys-mail1.physics.umd.edu>
Date: Mon, 23 Apr 2001 17:25:01 -0400 (EDT)
Message-Id: <200104232125.RAA03002@bofh.physics.umd.edu>
To: hesiod@mit.edu
Cc: payerle@physics.umd.edu
I was looking at making a PErl interface to the libhesiod api, and for
completeness was putting in hesiod_getservbyname call, even though not really
used in our setup. I was seeing some really wierd return values for port
numbers of standard services, which I eventually realized was an endian issue
(I was working on a little-endian Digital Unix alpha system).
Looking at the 3.0.2 source code
http://web.mit.edu/source/athena/lib/hesiod/hesservbyname.c
there is a line which I find rather questionable:
serv->s_port = htons(atoi(port));
Why do you have the htons call to translate to network byte order? port
contains the text/ASCII representation of the port number as returned in the
DNS TXT field, and atoi will then convert to an integer in the current machine
representation. As serv->s_port is an integer on the current machine, I
would expect it to be in the local machine representation also unless there
is some compelling reason I am missing (and if so, the man pages should clearly
say so). Presumably, any system calls spitting the port number back out
onto the net will take care of converting from local to network byte order,
so I would think the htons is erroneous. Just wanted to bring this to
someone's attention.
Tom Payerle
Dept of Physics payerle@physics.umd.edu
University of Maryland (301) 405-6973
College Park, MD 20742-4111 Fax: (301) 314-9525