Module Name:    src
Committed By:   ryo
Date:           Mon Mar 30 08:24:36 UTC 2020

Modified Files:
        src/lib/libutil: pidlock.c

Log Message:
fail to create a pidfile if hostname contains '/'


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/lib/libutil/pidlock.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libutil/pidlock.c
diff -u src/lib/libutil/pidlock.c:1.16 src/lib/libutil/pidlock.c:1.17
--- src/lib/libutil/pidlock.c:1.16	Sat Apr  7 16:17:17 2012
+++ src/lib/libutil/pidlock.c	Mon Mar 30 08:24:36 2020
@@ -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 <[email protected]>.
@@ -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 @@ pidlock(const char *lockfile, int flags,
 		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.

Reply via email to