File: fix_ftbfs.patch

package info (click to toggle)
ploop 1.15-12
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,372 kB
  • sloc: ansic: 16,133; sh: 413; makefile: 222; python: 144
file content (34 lines) | stat: -rw-r--r-- 913 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
Description: Fix ftbfs
 Use memcpy() instead of strncpy() to avoid the problem of copying more
 than the destination size. And at the same time break a snprintf() into
 multiple strcpy(), strcat() and strncat().

Forwarded: no
---

--- ploop-1.15.orig/lib/balloon.c
+++ ploop-1.15/lib/balloon.c
@@ -1172,8 +1172,10 @@ static void defrag_pidfile(const char *d
 {
 	char *p = strrchr(dev, '/');
 
-	snprintf(out, size, PLOOP_LOCK_DIR "/%s.defrag.pid",
-			p ? ++p : dev);
+	strcpy(out, PLOOP_LOCK_DIR);
+	strcat(out, "/");
+	strncat(out, p ? ++p : dev, size - strlen(out) - 1);
+	strncat(out, ".defrag.pid", size - strlen(out) - 1);
 }
 
 static void defrag_complete(const char *dev)
--- ploop-1.15.orig/lib/xml.c
+++ ploop-1.15/lib/xml.c
@@ -278,7 +278,7 @@ void get_basedir(const char *fname, char
 {
 	char *p;
 
-	strncpy(out, fname, len);
+	memcpy(out, fname, len);
 
 	p = strrchr(out, '/');
 	if (p != NULL)