From b4cc8687ad2950fd55dc93fb1f28ceaa28a30117 Mon Sep 17 00:00:00 2001 From: Tim Kientzle Date: Mon, 17 May 2004 06:17:59 +0000 Subject: [PATCH] If getpwent/getpwuid/getpwnam return NULL, they must also set errno. --- lib/libc/gen/getpwent.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/libc/gen/getpwent.c b/lib/libc/gen/getpwent.c index 96aee2e3741b..1753a83c8373 100644 --- a/lib/libc/gen/getpwent.c +++ b/lib/libc/gen/getpwent.c @@ -379,6 +379,7 @@ getpw(int (*fn)(union key, struct passwd *, char *, size_t, struct passwd **), free(pwd_storage); if ((pwd_storage_size << 1) > PWD_STORAGE_MAX) { pwd_storage = NULL; + errno = ERANGE; return (NULL); } pwd_storage_size <<= 1; @@ -387,6 +388,8 @@ getpw(int (*fn)(union key, struct passwd *, char *, size_t, struct passwd **), return (NULL); } } while (res == NULL && rv == ERANGE); + if (res == NULL) + errno = rv; return (res); }