lists.arthurdejong.org
RSS feed

Re: Incorrect service port handling in nss/services.c

[Date Prev][Date Next] [Thread Prev][Thread Next]

Re: Incorrect service port handling in nss/services.c



On Mon, 2010-07-26 at 17:24 -0700, Ted C. Cheng wrote:
> Thank you for the clarification. I think I am confused by the read_servent 
> routine under nss/services.c:
> 
> static enum nss_status read_servent(
>         TFILE *fp,struct servent *result,
>         char *buffer,size_t buflen,int *errnop)
> {
>    ...
>   /* store port number in network byte order */
>   READ_TYPE(fp,tmpint32,int32_t);
>   result->s_port=ntohs((uint16_t)tmpint32); <---
>   ...
>   return NSS_STATUS_SUCCESS;
> }
> 
> The comment mentioned that network byte order is used to store port number. 
> But "ntohs" is called for s_port, which seems to do the opposite.
> PADL implementation uses "htons", instead.

It should have been htons() in that function indeed. Thanks for pointing
it out (fixed now). The reason things still worked correctly is that
ntohs() and htons() do exactly the same thing.

-- 
-- arthur - arthur@arthurdejong.org - http://arthurdejong.org --
--
To unsubscribe send an email to
nss-pam-ldapd-users-unsubscribe@lists.arthurdejong.org or see
http://lists.arthurdejong.org/nss-pam-ldapd-users