From 1e720692ab14e6311c6a84cf4e331c08b82985a7 Mon Sep 17 00:00:00 2001 From: Theo de Raadt Date: Mon, 29 Sep 2003 15:52:29 +0000 Subject: unchecked strdup; ok henning; spotted by jjy2+@pitt.edu --- lib/libc/gen/getnetgrent.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/libc/gen/getnetgrent.c b/lib/libc/gen/getnetgrent.c index aec19041911..73cd0818a43 100644 --- a/lib/libc/gen/getnetgrent.c +++ b/lib/libc/gen/getnetgrent.c @@ -1,4 +1,4 @@ -/* $OpenBSD: getnetgrent.c,v 1.13 2002/07/06 03:07:41 deraadt Exp $ */ +/* $OpenBSD: getnetgrent.c,v 1.14 2003/09/29 15:52:28 deraadt Exp $ */ /* * Copyright (c) 1994 Christos Zoulas @@ -32,7 +32,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char *rcsid = "$OpenBSD: getnetgrent.c,v 1.13 2002/07/06 03:07:41 deraadt Exp $"; +static char *rcsid = "$OpenBSD: getnetgrent.c,v 1.14 2003/09/29 15:52:28 deraadt Exp $"; #endif /* LIBC_SCCS and not lint */ #include @@ -702,7 +702,7 @@ int innetgr(grp, host, user, domain) const char *grp, *host, *user, *domain; { - char *ypdom = NULL; + char *ypdom = NULL, *grpdup; #ifdef YP char *line = NULL; #endif @@ -738,9 +738,13 @@ innetgr(grp, host, user, domain) if (domain != NULL) return 0; + grpdup = strdup(grp); + if (grpdup == NULL) + return (0); + /* Too bad need the slow recursive way */ sl = _ng_sl_init(); - found = in_find(ypdom, sl, strdup(grp), host, user, domain); + found = in_find(ypdom, sl, grpdup, host, user, domain); _ng_sl_free(sl, 1); return found; -- cgit v1.2.3