From: Ulrich Drepper Date: Fri, 30 Jan 1998 17:18:19 +0000 (+0000) Subject: (getservbyport): Allow proto == NULL. X-Git-Tag: cvs/before-sparc-2_0_x-branch~248 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6ecb7620e5eaffeac8b8ccd3617b0eba28b408cf;p=thirdparty%2Fglibc.git (getservbyport): Allow proto == NULL. (getservbyname): Allow proto == NULL. --- diff --git a/nss/nss_files/files-service.c b/nss/nss_files/files-service.c index 317b4fa9cc8..b63fafcd1ee 100644 --- a/nss/nss_files/files-service.c +++ b/nss/nss_files/files-service.c @@ -1,5 +1,5 @@ /* Services file parser in nss_files module. - Copyright (C) 1996, 1997 Free Software Foundation, Inc. + Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -39,7 +39,8 @@ LINE_PARSER #include GENERIC -DB_LOOKUP (servbyname, 1 + strlen (name), (".%s/%s", name, proto), +DB_LOOKUP (servbyname, 2 + strlen (name) + (proto ? strlen (proto) : 0), + (".%s/%s", name, proto ?: ""), { /* Must match both protocol (if specified) and name. */ if (proto != NULL && strcmp (result->s_proto, proto)) @@ -48,10 +49,12 @@ DB_LOOKUP (servbyname, 1 + strlen (name), (".%s/%s", name, proto), }, const char *name, const char *proto) -DB_LOOKUP (servbyport, 20, ("=%d/%s", port, proto), +DB_LOOKUP (servbyport, 21 + (proto ? strlen (proto) : 0), + ("=%d/%s", ntohs (port), proto ?: ""), { /* Must match both port and protocol. */ - if (result->s_port == port - && strcmp (result->s_proto, proto) == 0) + if (result->s_port == ntohs (port) + && (proto == NULL + || strcmp (result->s_proto, proto) == 0)) break; }, int port, const char *proto)