diff options
| author | christos <christos@NetBSD.org> | 2005-04-19 03:29:18 +0000 |
|---|---|---|
| committer | christos <christos@NetBSD.org> | 2005-04-19 03:29:18 +0000 |
| commit | b9b92f846c1ae74cc341fbdbff37c1bba94bf5ff (patch) | |
| tree | 9f46c78b3f1e0cf21f9477f87788577eb44c296a /lib/libedit | |
| parent | cce62d09524e16c7b7eeed063ff8df5141980145 (diff) | |
check for pwd != NULL, fix a missed getpwnam.
Diffstat (limited to 'lib/libedit')
| -rw-r--r-- | lib/libedit/readline.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/lib/libedit/readline.c b/lib/libedit/readline.c index f16786b342b..327bbfd6d0e 100644 --- a/lib/libedit/readline.c +++ b/lib/libedit/readline.c @@ -1,4 +1,4 @@ -/* $NetBSD: readline.c,v 1.51 2005/04/12 22:01:40 christos Exp $ */ +/* $NetBSD: readline.c,v 1.52 2005/04/19 03:29:18 christos Exp $ */ /*- * Copyright (c) 1997 The NetBSD Foundation, Inc. @@ -38,7 +38,7 @@ #include "config.h" #if !defined(lint) && !defined(SCCSID) -__RCSID("$NetBSD: readline.c,v 1.51 2005/04/12 22:01:40 christos Exp $"); +__RCSID("$NetBSD: readline.c,v 1.52 2005/04/19 03:29:18 christos Exp $"); #endif /* not lint && not SCCSID */ #include <sys/types.h> @@ -1378,9 +1378,10 @@ history_search_pos(const char *str, char * tilde_expand(char *txt) { - struct passwd *pass; + struct passwd pwres, *pass; char *temp; size_t len = 0; + char pwbuf[1024]; if (txt[0] != '~') return (strdup(txt)); @@ -1398,7 +1399,8 @@ tilde_expand(char *txt) (void)strncpy(temp, txt + 1, len - 2); temp[len - 2] = '\0'; } - pass = getpwnam(temp); + if (getpwnam_r(temp, &pwres, pwbuf, sizeof(pwbuf), &pass) != 0) + pass = NULL; free(temp); /* value no more needed */ if (pass == NULL) return (strdup(txt)); @@ -1563,7 +1565,7 @@ username_completion_function(const char *text, int state) setpwent(); while (getpwent_r(&pwres, pwbuf, sizeof(pwbuf), &pwd) == 0 - && text[0] == pwd->pw_name[0] + && pwd != NULL && text[0] == pwd->pw_name[0] && strcmp(text, pwd->pw_name) == 0); if (pwd == NULL) { |
