This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[PATCH] getaddrinfo: Treat empty string as NULL
- From: Simon Perreault <simon dot perreault at viagenie dot ca>
- To: libc-alpha at sourceware dot org
- Date: Thu, 6 Sep 2007 08:43:31 -0400
- Subject: [PATCH] getaddrinfo: Treat empty string as NULL
Hi,
Shouldn't the empty string be treated as NULL, as is "*"?
(For the name and service parameters.)
See attached patch please.
Index: sysdeps/posix/getaddrinfo.c
===================================================================
RCS file: /cvs/glibc/libc/sysdeps/posix/getaddrinfo.c,v
retrieving revision 1.113
diff -u -r1.113 getaddrinfo.c
--- sysdeps/posix/getaddrinfo.c 28 Apr 2007 16:09:07 -0000 1.113
+++ sysdeps/posix/getaddrinfo.c 6 Sep 2007 12:33:31 -0000
@@ -1756,10 +1756,10 @@
struct gaih_service gaih_service, *pservice;
struct addrinfo local_hints;
- if (name != NULL && name[0] == '*' && name[1] == 0)
+ if (name != NULL && (name[0] == 0 || name[0] == '*' && name[1] == 0))
name = NULL;
- if (service != NULL && service[0] == '*' && service[1] == 0)
+ if (service != NULL && (service[0] == 0 || service[0] == '*' && service[1] == 0))
service = NULL;
if (name == NULL && service == NULL)