regression tests for bugs in first versions of new passwd code
[libc-test] / src / regression / getpwnam_r-crash.c
diff --git a/src/regression/getpwnam_r-crash.c b/src/regression/getpwnam_r-crash.c
new file mode 100644 (file)
index 0000000..1e65b7d
--- /dev/null
@@ -0,0 +1,13 @@
+// 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;
+}