summaryrefslogtreecommitdiff
path: root/pkgtools
diff options
context:
space:
mode:
authorwiz <wiz@pkgsrc.org>2006-04-04 06:34:25 +0000
committerwiz <wiz@pkgsrc.org>2006-04-04 06:34:25 +0000
commit786e9a25a2b58b31e6159aa6bd035689542fd81f (patch)
tree9b6cf0e11ea5bc580e49249f2d3c9e1c179435cc /pkgtools
parentae42a7bdb38a2dbaf4c63929240fb3b8bede28fb (diff)
downloadpkgsrc-786e9a25a2b58b31e6159aa6bd035689542fd81f.tar.gz
Pull over v1.36 from src/usr.sbin:
revision 1.36 date: 2006/03/17 01:58:25; author: hubertf; state: Exp; lines: +11 -3 We can't sprintf() into a NULL pointer - catch that properly for ALL cases. Coverity CID 861
Diffstat (limited to 'pkgtools')
-rw-r--r--pkgtools/pkg_install/files/lib/pen.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/pkgtools/pkg_install/files/lib/pen.c b/pkgtools/pkg_install/files/lib/pen.c
index 82fb8023882..87853083702 100644
--- a/pkgtools/pkg_install/files/lib/pen.c
+++ b/pkgtools/pkg_install/files/lib/pen.c
@@ -1,4 +1,4 @@
-/* $NetBSD: pen.c,v 1.18 2005/05/30 13:23:32 wiz Exp $ */
+/* $NetBSD: pen.c,v 1.19 2006/04/04 06:34:25 wiz Exp $ */
#if HAVE_CONFIG_H
#include "config.h"
@@ -11,7 +11,7 @@
#if 0
static const char *rcsid = "from FreeBSD Id: pen.c,v 1.25 1997/10/08 07:48:12 charnier Exp";
#else
-__RCSID("$NetBSD: pen.c,v 1.18 2005/05/30 13:23:32 wiz Exp $");
+__RCSID("$NetBSD: pen.c,v 1.19 2006/04/04 06:34:25 wiz Exp $");
#endif
#endif
@@ -103,7 +103,15 @@ find_play_pen(char *pen, size_t pensize, size_t sz)
char *cp;
struct stat sb;
- if (pen && pen[0] && stat(pen, &sb) != FAIL && (min_free(pen) >= sz))
+ if (pen == NULL) {
+ cleanup(0);
+ errx(2,
+ "find_play_pen(): 'pen' variable is NULL\n"
+ "(this should not happen, please report!");
+ return NULL;
+ }
+
+ if (pen[0] && stat(pen, &sb) != FAIL && (min_free(pen) >= sz))
return pen;
else if ((cp = getenv("PKG_TMPDIR")) != NULL && stat(cp, &sb) != FAIL && (min_free(cp) >= sz))
(void) snprintf(pen, pensize, "%s/instmp.XXXXXX", cp);