This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] nss_dns: Adjust ns_name_ntop failure handling in getnetby*


* DJ Delorie:

> Florian Weimer <fweimer@redhat.com> writes:
>> -      if (n > 0 && bp[0] == '.')
>> -	bp[0] = '\0';
>> -
>
>> +      if (bp[0] == '.')
>> +	bp[0] = '\0';
>
> This now references bp[0] when n == 0, which it didn't before.  But,
> ns_name_ntop always nul terminates the buffer, so bp[0] is always
> well-defined.  OK.  What about the case where __ns_name_unpack() returns
> zero?  It looks like that might have been a bug in the old version?

ns_name_unpack returns -1 on failure, and on success the length of the
name or name fragment in the original message.  That can never be zero.
It always includes at least the null terminate (one byte) or the
compression reference (two bytes).

The other question is whether it makes sense to rewrite "." (the only
possible output with a leading dot) to "".  I have really no idea why
the code does this.  It may be an attempt to remove a trailing dot '.',
but ns_name_ntop does not produce such names.

Hmm, I wonder if the "" case is one where the res_dnok actually fails.

Thanks,
Florian


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]