-
Notifications
You must be signed in to change notification settings - Fork 0
/
0082-nspawn-fix-use-after-free-and-leak-in-error-paths.patch
40 lines (31 loc) · 1.47 KB
/
0082-nspawn-fix-use-after-free-and-leak-in-error-paths.patch
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
35
36
37
38
39
40
From 28b5692e9ab3dbb07e4d6b8e44b370637c04ba86 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <[email protected]>
Date: Sat, 7 Mar 2015 14:19:20 -0500
Subject: [PATCH] nspawn: fix use-after-free and leak in error paths
CID #1257765.
(cherry picked from commit 8a16a7b4e7f6702a7e6edaead80ecf04be7d3ba2)
---
src/nspawn/nspawn.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c
index 7724df9..78bd584 100644
--- a/src/nspawn/nspawn.c
+++ b/src/nspawn/nspawn.c
@@ -3627,7 +3627,7 @@ int main(int argc, char *argv[]) {
}
if (arg_ephemeral) {
- char *np;
+ _cleanup_free_ char *np = NULL;
/* If the specified path is a mount point we
* generate the new snapshot immediately
@@ -3657,13 +3657,13 @@ int main(int argc, char *argv[]) {
r = btrfs_subvol_snapshot(arg_directory, np, arg_read_only, true);
if (r < 0) {
- free(np);
log_error_errno(r, "Failed to create snapshot %s from %s: %m", np, arg_directory);
goto finish;
}
free(arg_directory);
arg_directory = np;
+ np = NULL;
remove_subvol = true;