* regression tests for bugs in first versions of new passwd code
@ 2015-03-01 2:27 Rich Felker
0 siblings, 0 replies; only message in thread
From: Rich Felker @ 2015-03-01 2:27 UTC (permalink / raw)
To: musl
[-- Attachment #1: Type: text/plain, Size: 228 bytes --]
Here are a couple of tests, in the libc-test framework, for bugs that
affected the early versions of the new passwd code. I'd like to
eventually get some more extensive functionality coverage tests, but
these are a start.
Rich
[-- Attachment #2: getpwnam_r-crash.c --]
[-- Type: text/plain, Size: 300 bytes --]
// commit fc5a96c9c8aa186effad7520d5df6b616bbfd29d
// getpwnam_r should not crash on nonexistant users when errno is 0
#include <pwd.h>
#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;
}
[-- Attachment #3: getpwnam_r-errno.c --]
[-- Type: text/plain, Size: 478 bytes --]
// commit 0afef1aa24b784c86ae6121ca39e999824086c7c
// preexisting errno should not be interpreted by passwd/group functions
#include <pwd.h>
#include <errno.h>
#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;
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2015-03-01 2:27 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-01 2:27 regression tests for bugs in first versions of new passwd code Rich Felker
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/musl/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).