Blame SOURCES/0040-Fix-segfault-with-missing-lockfile-directory.patch

05e71a
From 97a7193e1838da9ab9631d07f6b3cedf63a5995d Mon Sep 17 00:00:00 2001
05e71a
From: Phil Sutter <phil@nwl.cc>
05e71a
Date: Tue, 9 Apr 2019 14:21:25 +0200
05e71a
Subject: [PATCH] Fix segfault with missing lockfile directory
05e71a
05e71a
Apparently, dirname() modifies the buffer passed to it. Given a
05e71a
read-only location, this leads to a segfault. Use a buffer initialized
05e71a
(and tailored) to the content of LOCKFILE macro at compile-time instead.
05e71a
05e71a
Fixes: f45756c1ca3b5 ("Allow customizing lockfile location at configure time")
05e71a
Signed-off-by: Phil Sutter <phil@nwl.cc>
05e71a
Signed-off-by: Florian Westphal <fw@strlen.de>
05e71a
(cherry picked from commit c9348e18f3cdd52a7cb1586e03a55cefac08d849)
05e71a
Signed-off-by: Phil Sutter <psutter@redhat.com>
05e71a
---
05e71a
 libebtc.c | 3 ++-
05e71a
 1 file changed, 2 insertions(+), 1 deletion(-)
05e71a
05e71a
diff --git a/libebtc.c b/libebtc.c
05e71a
index f2a2b500ea751..2a9ab87ac99c0 100644
05e71a
--- a/libebtc.c
05e71a
+++ b/libebtc.c
05e71a
@@ -140,12 +140,13 @@ int use_lockfd;
05e71a
  * or -2 on any other error. */
05e71a
 static int lock_file()
05e71a
 {
05e71a
+	char pathbuf[] = LOCKFILE;
05e71a
 	int fd, try = 0;
05e71a
 
05e71a
 retry:
05e71a
 	fd = open(LOCKFILE, O_CREAT, 00600);
05e71a
 	if (fd < 0) {
05e71a
-		if (try == 1 || mkdir(dirname(LOCKFILE), 00700))
05e71a
+		if (try == 1 || mkdir(dirname(pathbuf), 00700))
05e71a
 			return -2;
05e71a
 		try = 1;
05e71a
 		goto retry;
05e71a
-- 
05e71a
2.21.0
05e71a