libbb: fix use-after-free in copy_file
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
22a9951620
commit
3060992ec9
@ -388,14 +388,15 @@ int FAST_FUNC copy_file(const char *source, const char *dest, int flags)
|
|||||||
char *lpath = xmalloc_readlink_or_warn(source);
|
char *lpath = xmalloc_readlink_or_warn(source);
|
||||||
if (lpath) {
|
if (lpath) {
|
||||||
int r = symlink(lpath, dest);
|
int r = symlink(lpath, dest);
|
||||||
free(lpath);
|
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
/* shared message */
|
/* shared message */
|
||||||
bb_perror_msg("can't create %slink '%s' to '%s'",
|
bb_perror_msg("can't create %slink '%s' to '%s'",
|
||||||
"sym", dest, lpath
|
"sym", dest, lpath
|
||||||
);
|
);
|
||||||
|
free(lpath);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
free(lpath);
|
||||||
if (flags & FILEUTILS_PRESERVE_STATUS)
|
if (flags & FILEUTILS_PRESERVE_STATUS)
|
||||||
if (lchown(dest, source_stat.st_uid, source_stat.st_gid) < 0)
|
if (lchown(dest, source_stat.st_uid, source_stat.st_gid) < 0)
|
||||||
bb_perror_msg("can't preserve %s of '%s'", "ownership", dest);
|
bb_perror_msg("can't preserve %s of '%s'", "ownership", dest);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user