Terminate source correctly when copying symlink. Report and patch by
Brian Webb <webbb@desertscenes.net>.
This commit is contained in:
parent
088875fec4
commit
72ab975a6b
@ -200,13 +200,14 @@ int copy_file(const char *source, const char *dest, int flags)
|
|||||||
|
|
||||||
umask(saved_umask);
|
umask(saved_umask);
|
||||||
} else if (S_ISLNK(source_stat.st_mode)) {
|
} else if (S_ISLNK(source_stat.st_mode)) {
|
||||||
|
int size;
|
||||||
char buf[BUFSIZ + 1];
|
char buf[BUFSIZ + 1];
|
||||||
|
|
||||||
if (readlink(source, buf, BUFSIZ) < 0) {
|
if ((size = readlink(source, buf, BUFSIZ)) < 0) {
|
||||||
perror_msg("cannot read `%s'", source);
|
perror_msg("cannot read `%s'", source);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
buf[BUFSIZ] = '\0';
|
buf[size] = '\0';
|
||||||
|
|
||||||
if (symlink(buf, dest) < 0) {
|
if (symlink(buf, dest) < 0) {
|
||||||
perror_msg("cannot create symlink `%s'", dest);
|
perror_msg("cannot create symlink `%s'", dest);
|
||||||
|
Loading…
Reference in New Issue
Block a user