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