mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@libc.org>
To: musl@lists.openwall.com
Subject: regression tests for bugs in first versions of new passwd code
Date: Sat, 28 Feb 2015 21:27:29 -0500	[thread overview]
Message-ID: <20150301022729.GA8010@brightrain.aerifal.cx> (raw)

[-- 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;
}

                 reply	other threads:[~2015-03-01  2:27 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150301022729.GA8010@brightrain.aerifal.cx \
    --to=dalias@libc.org \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).