Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-1-5]: src/lib/libc/db/btree Pull up revision 1.15 (via patch, req...



details:   https://anonhg.NetBSD.org/src/rev/7c7be2eb41a3
branches:  netbsd-1-5
changeset: 493058:7c7be2eb41a3
user:      he <he%NetBSD.org@localhost>
date:      Wed Apr 17 11:22:49 2002 +0000

description:
Pull up revision 1.15 (via patch, requested by groo):
  Do not respect TMPDIR when setuid or setgid.

diffstat:

 lib/libc/db/btree/bt_open.c |  18 ++++++++++++------
 1 files changed, 12 insertions(+), 6 deletions(-)

diffs (43 lines):

diff -r 00eb701ac34c -r 7c7be2eb41a3 lib/libc/db/btree/bt_open.c
--- a/lib/libc/db/btree/bt_open.c       Thu Apr 11 22:59:29 2002 +0000
+++ b/lib/libc/db/btree/bt_open.c       Wed Apr 17 11:22:49 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: bt_open.c,v 1.13 1998/12/09 12:42:46 christos Exp $    */
+/*     $NetBSD: bt_open.c,v 1.13.10.1 2002/04/17 11:22:49 he Exp $     */
 
 /*-
  * Copyright (c) 1990, 1993, 1994
@@ -41,7 +41,7 @@
 #if 0
 static char sccsid[] = "@(#)bt_open.c  8.10 (Berkeley) 8/17/94";
 #else
-__RCSID("$NetBSD: bt_open.c,v 1.13 1998/12/09 12:42:46 christos Exp $");
+__RCSID("$NetBSD: bt_open.c,v 1.13.10.1 2002/04/17 11:22:49 he Exp $");
 #endif
 #endif /* LIBC_SCCS and not lint */
 
@@ -398,14 +398,20 @@
 tmp()
 {
        sigset_t set, oset;
-       int fd;
+       int fd, len;
        char *envtmp;
        char path[MAXPATHLEN];
 
-       envtmp = getenv("TMPDIR");
-       (void)snprintf(path,
+       if (issetugid())
+               envtmp = NULL;
+       else
+               envtmp = getenv("TMPDIR");
+
+       len = snprintf(path,
            sizeof(path), "%s/bt.XXXXXX", envtmp ? envtmp : _PATH_TMP);
-
+       if (len >= sizeof(path))
+               return -1;
+       
        (void)sigfillset(&set);
        (void)sigprocmask(SIG_BLOCK, &set, &oset);
        if ((fd = mkstemp(path)) != -1)



Home | Main Index | Thread Index | Old Index