diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2018-09-03 10:25:29 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2018-09-03 10:25:29 +0200 |
commit | 3060992ec94722b4f8f3711a1884270c81a6e5f5 (patch) | |
tree | 3cf8d86d4f93f86ba2626daa4ec24f5932567f16 | |
parent | 22a99516206b33b7ae124d426319bab03d5c8309 (diff) | |
download | busybox-w32-3060992ec94722b4f8f3711a1884270c81a6e5f5.tar.gz busybox-w32-3060992ec94722b4f8f3711a1884270c81a6e5f5.tar.bz2 busybox-w32-3060992ec94722b4f8f3711a1884270c81a6e5f5.zip |
libbb: fix use-after-free in copy_file
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | libbb/copy_file.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/libbb/copy_file.c b/libbb/copy_file.c index 98bd4fe72..2d6557cd4 100644 --- a/libbb/copy_file.c +++ b/libbb/copy_file.c | |||
@@ -388,14 +388,15 @@ int FAST_FUNC copy_file(const char *source, const char *dest, int flags) | |||
388 | char *lpath = xmalloc_readlink_or_warn(source); | 388 | char *lpath = xmalloc_readlink_or_warn(source); |
389 | if (lpath) { | 389 | if (lpath) { |
390 | int r = symlink(lpath, dest); | 390 | int r = symlink(lpath, dest); |
391 | free(lpath); | ||
392 | if (r < 0) { | 391 | if (r < 0) { |
393 | /* shared message */ | 392 | /* shared message */ |
394 | bb_perror_msg("can't create %slink '%s' to '%s'", | 393 | bb_perror_msg("can't create %slink '%s' to '%s'", |
395 | "sym", dest, lpath | 394 | "sym", dest, lpath |
396 | ); | 395 | ); |
396 | free(lpath); | ||
397 | return -1; | 397 | return -1; |
398 | } | 398 | } |
399 | free(lpath); | ||
399 | if (flags & FILEUTILS_PRESERVE_STATUS) | 400 | if (flags & FILEUTILS_PRESERVE_STATUS) |
400 | if (lchown(dest, source_stat.st_uid, source_stat.st_gid) < 0) | 401 | if (lchown(dest, source_stat.st_uid, source_stat.st_gid) < 0) |
401 | bb_perror_msg("can't preserve %s of '%s'", "ownership", dest); | 402 | bb_perror_msg("can't preserve %s of '%s'", "ownership", dest); |