From 1d863dc0b41da22b5a06110d67b47a0f102cb639 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Wed, 30 Jun 1999 17:41:35 +0000 Subject: Update. 1999-06-30 Ulrich Drepper * sysdeps/unix/sysv/linux/gethostid.c: Handle failing call to getxxbyYY_r functions correctly for non-existing entry. * sunrpc/getrpcport.c: Likewise. * sunrpc/clnt_simp.c: Likewise. * inet/rexec.c: Likewise. * sunrpc/clnt_gen.c: Likewise. * inet/rcmd.c: Likewise. * sysdeps/generic/glob.c: Likewise. --- ChangeLog | 11 +++++++++++ inet/rcmd.c | 12 ++++++++---- inet/rexec.c | 3 ++- pwd/pwd.h | 8 +++++++- sunrpc/clnt_gen.c | 6 ++++-- sunrpc/clnt_simp.c | 3 ++- sunrpc/getrpcport.c | 3 ++- sysdeps/generic/glob.c | 6 ++---- sysdeps/unix/sysv/linux/gethostid.c | 3 ++- 9 files changed, 40 insertions(+), 15 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8aaf893..49c5c4b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +1999-06-30 Ulrich Drepper + + * sysdeps/unix/sysv/linux/gethostid.c: Handle failing call to + getxxbyYY_r functions correctly for non-existing entry. + * sunrpc/getrpcport.c: Likewise. + * sunrpc/clnt_simp.c: Likewise. + * inet/rexec.c: Likewise. + * sunrpc/clnt_gen.c: Likewise. + * inet/rcmd.c: Likewise. + * sysdeps/generic/glob.c: Likewise. + 1999-06-29 Andreas Jaeger * pwd/Makefile (tests): Add rules for tst-getpw. diff --git a/inet/rcmd.c b/inet/rcmd.c index 923f21f..30f20d1 100644 --- a/inet/rcmd.c +++ b/inet/rcmd.c @@ -80,7 +80,8 @@ rcmd(ahost, rport, locuser, remuser, cmd, fd2p) hstbuflen = 1024; tmphstbuf = __alloca (hstbuflen); while (__gethostbyname_r (*ahost, &hostbuf, tmphstbuf, hstbuflen, - &hp, &herr) != 0) + &hp, &herr) != 0 + || hp == NULL) if (herr != NETDB_INTERNAL || errno != ERANGE) { __set_h_errno (herr); @@ -270,7 +271,8 @@ ruserok(rhost, superuser, ruser, luser) buffer = __alloca (buflen); while (__gethostbyname_r (rhost, &hostbuf, buffer, buflen, &hp, &herr) - != 0) + != 0 + || hp == NULL) if (herr != NETDB_INTERNAL || errno != ERANGE) return -1; else @@ -370,7 +372,8 @@ iruserok2 (raddr, superuser, ruser, luser, rhost) char *buffer = __alloca (buflen); uid_t uid; - if (__getpwnam_r (luser, &pwdbuf, buffer, buflen, &pwd)) + if (__getpwnam_r (luser, &pwdbuf, buffer, buflen, &pwd) != 0 + || pwd == NULL) return -1; dirlen = strlen (pwd->pw_dir); @@ -469,7 +472,8 @@ __icheckhost (raddr, lhost, rhost) buffer = __alloca (buflen); save_errno = errno; while (__gethostbyname_r (lhost, &hostbuf, buffer, buflen, &hp, &herr) - != 0) + != 0 + || hp = NULL) if (herr != NETDB_INTERNAL || errno != ERANGE) return (0); else { diff --git a/inet/rexec.c b/inet/rexec.c index 6ba7d20..897030e 100644 --- a/inet/rexec.c +++ b/inet/rexec.c @@ -64,7 +64,8 @@ rexec(ahost, rport, name, pass, cmd, fd2p) hstbuflen = 1024; hsttmpbuf = __alloca (hstbuflen); while (__gethostbyname_r (*ahost, &hostbuf, hsttmpbuf, hstbuflen, - &hp, &herr) != 0) + &hp, &herr) != 0 + || hp == NULL) if (herr != NETDB_INTERNAL || errno != ERANGE) { __set_h_errno (herr); diff --git a/pwd/pwd.h b/pwd/pwd.h index 50d62a1..a528a51 100644 --- a/pwd/pwd.h +++ b/pwd/pwd.h @@ -1,4 +1,4 @@ -/* Copyright (C) 1991, 92, 95, 96, 97, 98 Free Software Foundation, Inc. +/* Copyright (C) 1991, 92, 95, 96, 97, 98, 99 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 @@ -135,6 +135,12 @@ extern int fgetpwent_r __P ((FILE *__restrict __stream, #endif /* POSIX or reentrant */ +#ifdef __USE_GNU +/* Re-construct the password-file line for the given uid + in the given buffer. This knows the format that the caller + will expect, but this need not be the format of the password file. */ +extern int getpw __P ((__uid_t __uid, char *__buffer)); +#endif __END_DECLS diff --git a/sunrpc/clnt_gen.c b/sunrpc/clnt_gen.c index e8656ee..0f38857 100644 --- a/sunrpc/clnt_gen.c +++ b/sunrpc/clnt_gen.c @@ -78,7 +78,8 @@ clnt_create (const char *hostname, u_long prog, u_long vers, hstbuflen = 1024; hsttmpbuf = __alloca (hstbuflen); while (__gethostbyname_r (hostname, &hostbuf, hsttmpbuf, hstbuflen, - &h, &herr) != 0) + &h, &herr) != 0 + || h == NULL) if (herr != NETDB_INTERNAL || errno != ERANGE) { rpc_createerr.cf_stat = RPC_UNKNOWNHOST; @@ -107,7 +108,8 @@ clnt_create (const char *hostname, u_long prog, u_long vers, prtbuflen = 1024; prttmpbuf = __alloca (prtbuflen); - while (__getprotobyname_r (proto, &protobuf, prttmpbuf, prtbuflen, &p) != 0) + while (__getprotobyname_r (proto, &protobuf, prttmpbuf, prtbuflen, &p) != 0 + || p == NULL) if (errno != ERANGE) { rpc_createerr.cf_stat = RPC_UNKNOWNPROTO; diff --git a/sunrpc/clnt_simp.c b/sunrpc/clnt_simp.c index 41d106e..e1e7e2a 100644 --- a/sunrpc/clnt_simp.c +++ b/sunrpc/clnt_simp.c @@ -105,7 +105,8 @@ callrpc (const char *host, u_long prognum, u_long versnum, u_long procnum, buflen = 1024; buffer = __alloca (buflen); while (__gethostbyname_r (host, &hostbuf, buffer, buflen, - &hp, &herr) != 0) + &hp, &herr) != 0 + || hp == NULL) if (herr != NETDB_INTERNAL || errno != ERANGE) return (int) RPC_UNKNOWNHOST; else diff --git a/sunrpc/getrpcport.c b/sunrpc/getrpcport.c index 188c668..2e12482 100644 --- a/sunrpc/getrpcport.c +++ b/sunrpc/getrpcport.c @@ -56,7 +56,8 @@ getrpcport (const char *host, u_long prognum, u_long versnum, u_int proto) buflen = 1024; buffer = __alloca (buflen); - while (__gethostbyname_r (host, &hostbuf, buffer, buflen, &hp, &herr) != 0) + while (__gethostbyname_r (host, &hostbuf, buffer, buflen, &hp, &herr) != 0 + || hp == NULL) if (herr != NETDB_INTERNAL || errno != ERANGE) return 0; else diff --git a/sysdeps/generic/glob.c b/sysdeps/generic/glob.c index b48dd7c..9b134c5 100644 --- a/sysdeps/generic/glob.c +++ b/sysdeps/generic/glob.c @@ -650,13 +650,12 @@ glob (pattern, flags, errfunc, pglob) pwbuflen = 1024; pwtmpbuf = (char *) __alloca (pwbuflen); - success = 1; while (getpwnam_r (name, &pwbuf, pwtmpbuf, pwbuflen, &p) != 0) { if (errno != ERANGE) { - success = 0; + p = NULL; break; } pwbuflen *= 2; @@ -665,9 +664,8 @@ glob (pattern, flags, errfunc, pglob) } # else p = getpwnam (name); - success = p != NULL; # endif - if (success) + if (p != NULL) home_dir = p->pw_dir; } } diff --git a/sysdeps/unix/sysv/linux/gethostid.c b/sysdeps/unix/sysv/linux/gethostid.c index f2ebbf2..6f501e3 100644 --- a/sysdeps/unix/sysv/linux/gethostid.c +++ b/sysdeps/unix/sysv/linux/gethostid.c @@ -91,7 +91,8 @@ gethostid () /* To get the IP address we need to know the host name. */ while (__gethostbyname_r (hostname, &hostbuf, buffer, buflen, &hp, &herr) - != 0) + != 0 + || hp == NULL) if (herr != NETDB_INTERNAL || errno != ERANGE) return 0; else -- cgit v1.1