* [PATCH] nss_dns: More consistency in corrupt message handling in getnetby*
@ 2019-03-08 20:45 Florian Weimer
2019-03-11 21:35 ` DJ Delorie
0 siblings, 1 reply; 5+ messages in thread
From: Florian Weimer @ 2019-03-08 20:45 UTC (permalink / raw)
To: libc-alpha
If a parse error is encountered, fail with NO_RECOVERY and
NSS_STATUS_UNAVAIL.
2019-03-08 Florian Weimer <fweimer@redhat.com>
* resolv/nss_dns/dns-network.c (getanswer_r): Handle unparseable
messages more consistently.
diff --git a/resolv/nss_dns/dns-network.c b/resolv/nss_dns/dns-network.c
index 9c0082d270..68266d57c9 100644
--- a/resolv/nss_dns/dns-network.c
+++ b/resolv/nss_dns/dns-network.c
@@ -336,14 +336,11 @@ getanswer_r (const querybuf *answer, int anslen, struct netent *result,
bp[0] = '\0';
if (n < 0)
- break;
+ goto bad_message;
cp += n;
if (end_of_message - cp < 10)
- {
- __set_h_errno (NO_RECOVERY);
- return NSS_STATUS_UNAVAIL;
- }
+ goto bad_message;
int type, class;
GETSHORT (type, cp);
@@ -352,10 +349,7 @@ getanswer_r (const querybuf *answer, int anslen, struct netent *result,
uint16_t rdatalen;
GETSHORT (rdatalen, cp);
if (end_of_message - cp < rdatalen)
- {
- __set_h_errno (NO_RECOVERY);
- return NSS_STATUS_UNAVAIL;
- }
+ goto bad_message;
if (class == C_IN && type == T_PTR)
{
@@ -370,13 +364,7 @@ getanswer_r (const querybuf *answer, int anslen, struct netent *result,
}
if (n < 0)
- {
- /* XXX What does this mean? The original form from bind
- returns NULL. Incrementing cp has no effect in any case.
- What should I return here. ??? */
- cp += n;
- return NSS_STATUS_UNAVAIL;
- }
+ goto bad_message;
cp += rdatalen;
if (alias_pointer + 2 < &net_data->aliases[MAX_NR_ALIASES])
{
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] nss_dns: More consistency in corrupt message handling in getnetby*
2019-03-08 20:45 [PATCH] nss_dns: More consistency in corrupt message handling in getnetby* Florian Weimer
@ 2019-03-11 21:35 ` DJ Delorie
2019-03-11 21:52 ` Florian Weimer
0 siblings, 1 reply; 5+ messages in thread
From: DJ Delorie @ 2019-03-11 21:35 UTC (permalink / raw)
To: Florian Weimer; +Cc: libc-alpha
Florian Weimer <fweimer@redhat.com> writes:
> If a parse error is encountered, fail with NO_RECOVERY and
> NSS_STATUS_UNAVAIL.
>
> 2019-03-08 Florian Weimer <fweimer@redhat.com>
>
> * resolv/nss_dns/dns-network.c (getanswer_r): Handle unparseable
> messages more consistently.
LGTM but depends on the errno question from the previous (dependency)
patch.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] nss_dns: More consistency in corrupt message handling in getnetby*
2019-03-11 21:35 ` DJ Delorie
@ 2019-03-11 21:52 ` Florian Weimer
2019-03-11 21:57 ` DJ Delorie
0 siblings, 1 reply; 5+ messages in thread
From: Florian Weimer @ 2019-03-11 21:52 UTC (permalink / raw)
To: DJ Delorie; +Cc: libc-alpha
* DJ Delorie:
> Florian Weimer <fweimer@redhat.com> writes:
>> If a parse error is encountered, fail with NO_RECOVERY and
>> NSS_STATUS_UNAVAIL.
>>
>> 2019-03-08 Florian Weimer <fweimer@redhat.com>
>>
>> * resolv/nss_dns/dns-network.c (getanswer_r): Handle unparseable
>> messages more consistently.
>
> LGTM but depends on the errno question from the previous (dependency)
> patch.
Setting errno to any value is fine as long it's not 0 or ERANGE. 8-)
Thanks,
Florian
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] nss_dns: More consistency in corrupt message handling in getnetby*
2019-03-11 21:52 ` Florian Weimer
@ 2019-03-11 21:57 ` DJ Delorie
2019-04-08 10:20 ` Florian Weimer
0 siblings, 1 reply; 5+ messages in thread
From: DJ Delorie @ 2019-03-11 21:57 UTC (permalink / raw)
To: Florian Weimer; +Cc: libc-alpha
Florian Weimer <fweimer@redhat.com> writes:
> Setting errno to any value is fine as long it's not 0 or ERANGE. 8-)
I was thinking back to a conversation (maybe here) about polluting errno
by setting it *at all* in functions that should only set h_errno. So, I
flagged a change in whether or not errno was set. I don't know if that
rule applies in this case, but we should at least know if it does or
not, and say so, so we don't unintentionally make things worse.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] nss_dns: More consistency in corrupt message handling in getnetby*
2019-03-11 21:57 ` DJ Delorie
@ 2019-04-08 10:20 ` Florian Weimer
0 siblings, 0 replies; 5+ messages in thread
From: Florian Weimer @ 2019-04-08 10:20 UTC (permalink / raw)
To: DJ Delorie; +Cc: libc-alpha
* DJ Delorie:
> Florian Weimer <fweimer@redhat.com> writes:
>> Setting errno to any value is fine as long it's not 0 or ERANGE. 8-)
>
> I was thinking back to a conversation (maybe here) about polluting errno
> by setting it *at all* in functions that should only set h_errno.
I'm not aware of such a discussion. The h_errno == NETDB_INTERNAL
definitely needs to set errno, to name just one example.
What do you think about the nss_dns patch, given this aspect?
Thanks,
Florian
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2019-04-08 10:20 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-08 20:45 [PATCH] nss_dns: More consistency in corrupt message handling in getnetby* Florian Weimer
2019-03-11 21:35 ` DJ Delorie
2019-03-11 21:52 ` Florian Weimer
2019-03-11 21:57 ` DJ Delorie
2019-04-08 10:20 ` Florian Weimer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).