From: Szabolcs Nagy Date: Sun, 1 Mar 2015 10:59:17 +0000 (+0100) Subject: regression tests for bugs in first versions of new passwd code X-Git-Url: http://nsz.repo.hu/git/?a=commitdiff_plain;ds=inline;h=768454361dff32b730136084ff94dbfa4887d82f;p=libc-test regression tests for bugs in first versions of new passwd code --- diff --git a/src/regression/getpwnam_r-crash.c b/src/regression/getpwnam_r-crash.c new file mode 100644 index 0000000..1e65b7d --- /dev/null +++ b/src/regression/getpwnam_r-crash.c @@ -0,0 +1,13 @@ +// commit fc5a96c9c8aa186effad7520d5df6b616bbfd29d +// getpwnam_r should not crash on nonexistant users when errno is 0 + +#include +#include "test.h" + +int main(void) +{ + struct passwd *pw, pwbuf; + char buf[1024]; + getpwnam_r("nonsensical_user", &pwbuf, buf, sizeof buf, &pw); + return t_status; +} diff --git a/src/regression/getpwnam_r-errno.c b/src/regression/getpwnam_r-errno.c new file mode 100644 index 0000000..bb8685e --- /dev/null +++ b/src/regression/getpwnam_r-errno.c @@ -0,0 +1,17 @@ +// commit 0afef1aa24b784c86ae6121ca39e999824086c7c +// preexisting errno should not be interpreted by passwd/group functions + +#include +#include +#include "test.h" + +int main(void) +{ + int baderr = EOWNERDEAD; // arbitrary absurd error + struct passwd *pw, pwbuf; + char buf[1024]; + errno = baderr; + if (getpwnam_r("nonsensical_user", &pwbuf, buf, sizeof buf, &pw) == baderr) + t_error("getpwnam_r used preexisting errno for nonexisting user\n"); + return t_status; +}