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] getaddrinfo: Use &errno has the errno pointer


My only real concern about this patch set is...

fweimer@redhat.com (Florian Weimer) writes:
>      status = DL_CALL_FCT (fct, (name, _family, &th,			      \
>  				tmpbuf->data, tmpbuf->length,		      \
> -				&rc, &herrno, NULL, &localcanon));	      \
> -    if (rc != ERANGE || herrno != NETDB_INTERNAL)			      \
> +				&errno, &herrno, NULL, &localcanon));	      \
> +    if (errno != ERANGE || herrno != NETDB_INTERNAL)			      \

Are we sure that errno will not *already* be ERANGE when the function is
called?  IIRC it's the app's responsibility to zero it out after it's
dealt with the errors, so there's a chance it will happen to have the
"right" error already, and you'll test a false positive here.

The original code avoided this by setting rc to 0 before calling.


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