summaryrefslogtreecommitdiffstats
path: root/lib/libc/asr/asr_resolver.c
diff options
context:
space:
mode:
authoreric <eric@openbsd.org>2012-08-18 13:49:13 +0000
committereric <eric@openbsd.org>2012-08-18 13:49:13 +0000
commit987f89cf3e6f1937a715ddb3c66055ada5385c7e (patch)
tree4fffc38419d5146b4beafc4dab6deec421bde7bd /lib/libc/asr/asr_resolver.c
parentSimplify error reporting in hostaddr_async(). Only use EAI_* error codes. (diff)
downloadwireguard-openbsd-987f89cf3e6f1937a715ddb3c66055ada5385c7e.tar.xz
wireguard-openbsd-987f89cf3e6f1937a715ddb3c66055ada5385c7e.zip
getrrsetyname() only uses ERRSET_* and is not supposed to set errno.
make sure to save and restore errno properly.
Diffstat (limited to 'lib/libc/asr/asr_resolver.c')
-rw-r--r--lib/libc/asr/asr_resolver.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/lib/libc/asr/asr_resolver.c b/lib/libc/asr/asr_resolver.c
index 7de2e3acb5c..ab996fd97b6 100644
--- a/lib/libc/asr/asr_resolver.c
+++ b/lib/libc/asr/asr_resolver.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: asr_resolver.c,v 1.6 2012/08/18 11:19:51 eric Exp $ */
+/* $OpenBSD: asr_resolver.c,v 1.7 2012/08/18 13:49:13 eric Exp $ */
/*
* Copyright (c) 2012 Eric Faurot <eric@openbsd.org>
*
@@ -226,17 +226,20 @@ getrrsetbyname(const char *name, unsigned int class, unsigned int type,
{
struct async *as;
struct async_res ar;
+ int r, saved_errno = errno;
as = getrrsetbyname_async(name, class, type, flags, NULL);
- if (as == NULL)
- return (errno == ENOMEM) ? ERRSET_NOMEMORY : ERRSET_FAIL;
+ if (as == NULL) {
+ r = (errno == ENOMEM) ? ERRSET_NOMEMORY : ERRSET_FAIL;
+ errno = saved_errno;
+ return (r);
+ }
async_run_sync(as, &ar);
- if (ar.ar_errno)
- errno = ar.ar_errno;
-
+ errno = saved_errno;
*res = ar.ar_rrsetinfo;
+
return (ar.ar_rrset_errno);
}