diff options
author | Eric Faurot <eric@cvs.openbsd.org> | 2012-08-18 13:49:14 +0000 |
---|---|---|
committer | Eric Faurot <eric@cvs.openbsd.org> | 2012-08-18 13:49:14 +0000 |
commit | 3521a9c09e3a4ef204505047ca1a9e70f7c32e9c (patch) | |
tree | 098b5a96637eb00ab17c96245f4ce71844752c4b | |
parent | c87eb78820da4cc07405d6f076b5c165e387e377 (diff) |
getrrsetyname() only uses ERRSET_* and is not supposed to set errno.
make sure to save and restore errno properly.
-rw-r--r-- | lib/libc/asr/asr_resolver.c | 15 | ||||
-rw-r--r-- | lib/libc/asr/getrrsetbyname_async.c | 9 |
2 files changed, 12 insertions, 12 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); } diff --git a/lib/libc/asr/getrrsetbyname_async.c b/lib/libc/asr/getrrsetbyname_async.c index 10707f8518c..d673a8896b1 100644 --- a/lib/libc/asr/getrrsetbyname_async.c +++ b/lib/libc/asr/getrrsetbyname_async.c @@ -1,4 +1,4 @@ -/* $OpenBSD: getrrsetbyname_async.c,v 1.1 2012/04/14 09:24:18 eric Exp $ */ +/* $OpenBSD: getrrsetbyname_async.c,v 1.2 2012/08/18 13:49:13 eric Exp $ */ /* * Copyright (c) 2012 Eric Faurot <eric@openbsd.org> * @@ -155,15 +155,12 @@ getrrsetbyname_async_run(struct async *as, struct async_res *ar) break; case ASR_STATE_HALT: - if (ar->ar_rrset_errno) ar->ar_rrsetinfo = NULL; return (ASYNC_DONE); default: - ar->ar_errno = EOPNOTSUPP; - ar->ar_h_errno = NETDB_INTERNAL; - ar->ar_gai_errno = EAI_SYSTEM; + ar->ar_rrset_errno = ERRSET_FAIL; async_set_state(as, ASR_STATE_HALT); break; } @@ -172,7 +169,7 @@ getrrsetbyname_async_run(struct async *as, struct async_res *ar) /* The rest of this file is taken from the orignal implementation. */ -/* $OpenBSD: getrrsetbyname_async.c,v 1.1 2012/04/14 09:24:18 eric Exp $ */ +/* $OpenBSD: getrrsetbyname_async.c,v 1.2 2012/08/18 13:49:13 eric Exp $ */ /* * Copyright (c) 2001 Jakob Schlyter. All rights reserved. |