From 8ccc7922d7a201cac4bfd8c07208604a6fbe29f4 Mon Sep 17 00:00:00 2001 From: deraadt <> Date: Sun, 30 Mar 2003 20:57:59 +0000 Subject: [PATCH] asprintf; millert ok --- src/lib/libutil/passwd.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/lib/libutil/passwd.c b/src/lib/libutil/passwd.c index fbd2d730..38ae21e1 100644 --- a/src/lib/libutil/passwd.c +++ b/src/lib/libutil/passwd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: passwd.c,v 1.36 2002/07/31 21:53:34 millert Exp $ */ +/* $OpenBSD: passwd.c,v 1.37 2003/03/30 20:57:59 deraadt Exp $ */ /* * Copyright (c) 1987, 1993, 1994, 1995 @@ -34,7 +34,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static const char rcsid[] = "$OpenBSD: passwd.c,v 1.36 2002/07/31 21:53:34 millert Exp $"; +static const char rcsid[] = "$OpenBSD: passwd.c,v 1.37 2003/03/30 20:57:59 deraadt Exp $"; #endif /* LIBC_SCCS and not lint */ #include @@ -143,10 +143,9 @@ pw_file(nm) p++; else p = nm; - new_nm = malloc(strlen(pw_dir) + strlen(p) + 2); - if (!new_nm) + + if (asprintf(&new_nm, "%s/%s", pw_dir, p) == -1) return NULL; - sprintf(new_nm, "%s/%s", pw_dir, p); return new_nm; }