projects
/
platform
/
upstream
/
systemd.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
2b6d2dd
)
fs-util: chase_symlinks(): prevent double free
author
Yu Watanabe
<watanabe.yu+github@gmail.com>
Sun, 21 Jan 2018 10:19:25 +0000
(19:19 +0900)
committer
Yu Watanabe
<watanabe.yu+github@gmail.com>
Sun, 21 Jan 2018 10:19:28 +0000
(19:19 +0900)
Fixes CID #1385316.
src/basic/fs-util.c
patch
|
blob
|
history
diff --git
a/src/basic/fs-util.c
b/src/basic/fs-util.c
index
87d743b
..
a8e50d4
100644
(file)
--- a/
src/basic/fs-util.c
+++ b/
src/basic/fs-util.c
@@
-834,8
+834,6
@@
int chase_symlinks(const char *path, const char *original_root, unsigned flags,
if (fd < 0)
return -errno;
- free(done);
-
if (flags & CHASE_SAFE) {
if (fstat(fd, &st) < 0)
return -errno;
@@
-846,6
+844,8
@@
int chase_symlinks(const char *path, const char *original_root, unsigned flags,
previous_stat = st;
}
+ free(done);
+
/* Note that we do not revalidate the root, we take it as is. */
if (isempty(root))
done = NULL;