From 0657965007f90112353fb1f1de29e606be1eea74 Mon Sep 17 00:00:00 2001 From: florian Date: Wed, 22 Nov 2023 13:19:31 +0000 Subject: [PATCH] Set correct errno field in struct asr_result. Otherwise gethostbyname(3) returns stack garbage when it is called with an invalid host name, indicating success. Problem observed in segfaulting ifconfig(8) by bluhm. --- lib/libc/asr/gethostnamadr_async.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/libc/asr/gethostnamadr_async.c b/lib/libc/asr/gethostnamadr_async.c index ed998cfde0c..c570be34d38 100644 --- a/lib/libc/asr/gethostnamadr_async.c +++ b/lib/libc/asr/gethostnamadr_async.c @@ -1,4 +1,4 @@ -/* $OpenBSD: gethostnamadr_async.c,v 1.48 2023/11/20 12:15:16 florian Exp $ */ +/* $OpenBSD: gethostnamadr_async.c,v 1.49 2023/11/22 13:19:31 florian Exp $ */ /* * Copyright (c) 2012 Eric Faurot * @@ -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; } -- 2.20.1