On 2023-11-20 23:33 +01, Alexander Bluhm <[email protected]> wrote:
> On Tue, Nov 14, 2023 at 01:27:33AM -0700, Florian Obser wrote:
>> CVSROOT: /cvs
>> Module name: src
>> Changes by: [email protected] 2023/11/14 01:27:33
>>
>> Modified files:
>> lib/libc/asr : gethostnamadr_async.c
>>
>> Log message:
>> Add break to error out on weird characters in gethostbyname().
>>
>> Missed in previous some time ago; while here remove confusing else.
>>
>> Input & OK eric
>
> This breaks DNS error handling in ifconfig.
>
> # ifconfig foo0 foo:bar
> Segmentation fault (core dumped)
>
> #0 0x000005eb2d9dc132 in in_getaddr (s=0x70483ea0f184 "foo:bar", which=1)
> at /usr/src/sbin/ifconfig/ifconfig.c:6413
> 6413 memcpy(&sin->sin_addr, hp->h_addr,
> hp->h_length);
>
> bluhm
We need to set the correct ar_ errno, otherwise we return stack garbage.
OK?
diff --git gethostnamadr_async.c gethostnamadr_async.c
index d211679400b..5dfaaaa767c 100644
--- gethostnamadr_async.c
+++ gethostnamadr_async.c
@@ -205,7 +205,8 @@ gethostnamadr_async_run(struct asr_query *as, struct
asr_result *ar)
}
if (!hnok_lenient(as->as.hostnamadr.name)) {
- ar->ar_gai_errno = EAI_FAIL;
+ ar->ar_h_errno = NETDB_INTERNAL;
+ ar->ar_errno = EINVAL;
async_set_state(as, ASR_STATE_HALT);
break;
}
--
In my defence, I have been left unsupervised.