Make queries using the search list for hostname lookups fail with
authoreric <eric@openbsd.org>
Wed, 23 Jul 2014 21:26:25 +0000 (21:26 +0000)
committereric <eric@openbsd.org>
Wed, 23 Jul 2014 21:26:25 +0000 (21:26 +0000)
NO_DATA/EAI_NODATA when the hostname param is an empty string.
So far, they were using the entries in the search list with no
additional component, which is not really expected.

reported by jsing@ and a few others

ok deraadt@, "makes sense" jsing@

lib/libc/asr/getaddrinfo_async.c
lib/libc/asr/gethostnamadr_async.c
lib/libc/asr/getnetnamadr_async.c
lib/libc/asr/res_search_async.c

index 94b071a..1a4e733 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: getaddrinfo_async.c,v 1.28 2014/05/10 21:21:09 chl Exp $      */
+/*     $OpenBSD: getaddrinfo_async.c,v 1.29 2014/07/23 21:26:25 eric Exp $     */
 /*
  * Copyright (c) 2012 Eric Faurot <eric@openbsd.org>
  *
@@ -157,6 +157,12 @@ getaddrinfo_async_run(struct asr_query *as, struct asr_result *ar)
                        break;
                }
 
+               if (as->as.ai.hostname && as->as.ai.hostname[0] == '\0') {
+                       ar->ar_gai_errno = EAI_NODATA;
+                       async_set_state(as, ASR_STATE_HALT);
+                       break;
+               }
+               
                ai = &as->as.ai.hints;
 
                if (ai->ai_addrlen ||
index f94d410..218c055 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: gethostnamadr_async.c,v 1.29 2014/05/13 11:57:35 eric Exp $   */
+/*     $OpenBSD: gethostnamadr_async.c,v 1.30 2014/07/23 21:26:25 eric Exp $   */
 /*
  * Copyright (c) 2012 Eric Faurot <eric@openbsd.org>
  *
@@ -173,8 +173,15 @@ gethostnamadr_async_run(struct asr_query *as, struct asr_result *ar)
                        break;
                }
 
-               /* Name might be an IP address string */
                if (as->as_type == ASR_GETHOSTBYNAME) {
+
+                       if (as->as.hostnamadr.name[0] == '\0') {
+                               ar->ar_h_errno = NO_DATA;
+                               async_set_state(as, ASR_STATE_HALT);
+                               break;
+                       }
+
+                       /* Name might be an IP address string */
                        for (c = as->as.hostnamadr.name; *c; c++)
                                if (!isdigit((unsigned char)*c) &&
                                     *c != '.' && *c != ':')
index f030ca9..77f77cc 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: getnetnamadr_async.c,v 1.15 2014/05/13 11:57:35 eric Exp $    */
+/*     $OpenBSD: getnetnamadr_async.c,v 1.16 2014/07/23 21:26:25 eric Exp $    */
 /*
  * Copyright (c) 2012 Eric Faurot <eric@openbsd.org>
  *
@@ -125,6 +125,13 @@ getnetnamadr_async_run(struct asr_query *as, struct asr_result *ar)
                        break;
                }
 
+               if (as->as_type == ASR_GETNETBYNAME &&
+                   as->as.netnamadr.name[0] == '\0') {
+                       ar->ar_h_errno = NO_DATA;
+                       async_set_state(as, ASR_STATE_HALT);
+                       break;
+               }
+
                async_set_state(as, ASR_STATE_NEXT_DB);
                break;
 
index d040655..38c3212 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: res_search_async.c,v 1.13 2014/03/26 18:13:15 eric Exp $      */
+/*     $OpenBSD: res_search_async.c,v 1.14 2014/07/23 21:26:25 eric Exp $      */
 /*
  * Copyright (c) 2012 Eric Faurot <eric@openbsd.org>
  *
@@ -94,6 +94,12 @@ res_search_async_run(struct asr_query *as, struct asr_result *ar)
 
        case ASR_STATE_INIT:
 
+               if (as->as.search.name[0] == '\0') {
+                       ar->ar_h_errno = NO_DATA;
+                       async_set_state(as, ASR_STATE_HALT);
+                       break;
+               }
+
                as->as.search.saved_h_errno = HERRNO_UNSET;
                async_set_state(as, ASR_STATE_NEXT_DOMAIN);
                break;