Source-Changes-HG archive

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

[src/trunk]: src/lib/libutil fail to create a pidfile if hostname contains '/'



details:   https://anonhg.NetBSD.org/src/rev/bccf11cc117a
branches:  trunk
changeset: 746385:bccf11cc117a
user:      ryo <ryo%NetBSD.org@localhost>
date:      Mon Mar 30 08:24:36 2020 +0000

description:
fail to create a pidfile if hostname contains '/'

diffstat:

 lib/libutil/pidlock.c |  10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)

diffs (31 lines):

diff -r 13235e6107f1 -r bccf11cc117a lib/libutil/pidlock.c
--- a/lib/libutil/pidlock.c     Mon Mar 30 06:56:38 2020 +0000
+++ b/lib/libutil/pidlock.c     Mon Mar 30 08:24:36 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pidlock.c,v 1.16 2012/04/07 16:17:17 christos Exp $ */
+/*     $NetBSD: pidlock.c,v 1.17 2020/03/30 08:24:36 ryo Exp $ */
 
 /*
  * Copyright 1996, 1997 by Curt Sampson <cjs%NetBSD.org@localhost>.
@@ -24,7 +24,7 @@
 
 #include <sys/cdefs.h>
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: pidlock.c,v 1.16 2012/04/07 16:17:17 christos Exp $");
+__RCSID("$NetBSD: pidlock.c,v 1.17 2020/03/30 08:24:36 ryo Exp $");
 #endif /* LIBC_SCCS and not lint */
 
 #include <sys/param.h>
@@ -67,6 +67,12 @@
                return -1;
        hostname[sizeof(hostname) - 1] = '\0';
 
+       /* avoid '/' in hostname, as it may contain arbitrary characters */
+       for (p = hostname; *p != '\0'; p++) {
+               if (*p == '/')
+                       *p = '_';
+       }
+
        /*
         * Build a path to the temporary file.
         * We use the path with the PID and hostname appended.



Home | Main Index | Thread Index | Old Index