diff options
| author | 2015-06-03 02:24:36 +0000 | |
|---|---|---|
| committer | 2015-06-03 02:24:36 +0000 | |
| commit | aa48e8d13779c959af7d1e175e87101276d885ff (patch) | |
| tree | 386ae5a481a265f981601e62dce9123561813c69 /lib/libc | |
| parent | better description of internal copyn() function (diff) | |
| download | wireguard-openbsd-aa48e8d13779c959af7d1e175e87101276d885ff.tar.xz wireguard-openbsd-aa48e8d13779c959af7d1e175e87101276d885ff.zip | |
Do not assume that asprintf() clears the pointer on failure, which
is non-portable. Also add missing asprintf() return value checks.
OK deraadt@ guenther@ doug@
Diffstat (limited to 'lib/libc')
| -rw-r--r-- | lib/libc/gen/getgrouplist.c | 6 | ||||
| -rw-r--r-- | lib/libc/gen/getpwent.c | 12 |
2 files changed, 12 insertions, 6 deletions
diff --git a/lib/libc/gen/getgrouplist.c b/lib/libc/gen/getgrouplist.c index 651231124dd..79f6da75e8b 100644 --- a/lib/libc/gen/getgrouplist.c +++ b/lib/libc/gen/getgrouplist.c @@ -1,4 +1,4 @@ -/* $OpenBSD: getgrouplist.c,v 1.24 2014/09/15 06:15:48 guenther Exp $ */ +/* $OpenBSD: getgrouplist.c,v 1.25 2015/06/03 02:24:36 millert Exp $ */ /* * Copyright (c) 2008 Ingo Schwarze <schwarze@usta.de> * Copyright (c) 1991, 1993 @@ -204,8 +204,8 @@ getgrouplist(const char *uname, gid_t agroup, gid_t *groups, int *grpcnt) if (getpwnam_r(uname, &pwstore, buf, sizeof buf, NULL) || (!__ypdomain && yp_get_default_domain(&__ypdomain))) goto out; - asprintf(&key, "unix.%u@%s", pwstore.pw_uid, __ypdomain); - if (key == NULL) + i = asprintf(&key, "unix.%u@%s", pwstore.pw_uid, __ypdomain); + if (i == -1) goto out; /* First scan the static netid file. */ diff --git a/lib/libc/gen/getpwent.c b/lib/libc/gen/getpwent.c index 45f64fdf873..2d58e3f9bec 100644 --- a/lib/libc/gen/getpwent.c +++ b/lib/libc/gen/getpwent.c @@ -1,4 +1,4 @@ -/* $OpenBSD: getpwent.c,v 1.53 2015/01/16 16:48:51 deraadt Exp $ */ +/* $OpenBSD: getpwent.c,v 1.54 2015/06/03 02:24:36 millert Exp $ */ /* * Copyright (c) 2008 Theo de Raadt * Copyright (c) 1988, 1993 @@ -542,11 +542,17 @@ __yppwlookup(int lookup, char *name, uid_t uid, struct passwd *pw, __ypproto_set(pw, yppbuf, *flagsp, &yp_pw_flags); if (!map) { if (lookup == LOOKUP_BYNAME) { + if ((name = strdup(name)) == NULL) { + pw = NULL; + goto done; + } map = PASSWD_BYNAME; - name = strdup(name); } else { + if (asprintf(&name, "%u", uid) == -1) { + pw = NULL; + goto done; + } map = PASSWD_BYUID; - asprintf(&name, "%u", uid); } } |
