bin/xbps-create/main.c: fix CID 62686 correctly; all tests pass now.
This commit is contained in:
parent
9f873072b4
commit
f7441d24cf
@ -464,7 +464,7 @@ process_entry_file(struct archive *ar,
|
|||||||
{
|
{
|
||||||
struct archive_entry *entry, *sparse_entry;
|
struct archive_entry *entry, *sparse_entry;
|
||||||
struct stat st;
|
struct stat st;
|
||||||
char buf[16384], *p;
|
char *buf = NULL, *p;
|
||||||
ssize_t len;
|
ssize_t len;
|
||||||
|
|
||||||
assert(ar);
|
assert(ar);
|
||||||
@ -493,11 +493,13 @@ process_entry_file(struct archive *ar,
|
|||||||
archive_entry_set_gname(entry, "root");
|
archive_entry_set_gname(entry, "root");
|
||||||
|
|
||||||
if (S_ISLNK(st.st_mode)) {
|
if (S_ISLNK(st.st_mode)) {
|
||||||
len = readlink(p, buf, sizeof(buf));
|
buf = malloc(st.st_size+1);
|
||||||
|
assert(buf);
|
||||||
|
len = readlink(p, buf, st.st_size+1);
|
||||||
if (len < 0 || len > st.st_size)
|
if (len < 0 || len > st.st_size)
|
||||||
die("failed to add entry %s (readlink) to archive:",
|
die("failed to add entry %s (readlink) to archive:",
|
||||||
xe->file);
|
xe->file);
|
||||||
buf[len-1] = '\0';
|
buf[len] = '\0';
|
||||||
archive_entry_set_symlink(entry, buf);
|
archive_entry_set_symlink(entry, buf);
|
||||||
}
|
}
|
||||||
free(p);
|
free(p);
|
||||||
@ -508,6 +510,8 @@ process_entry_file(struct archive *ar,
|
|||||||
write_entry(ar, entry);
|
write_entry(ar, entry);
|
||||||
if (sparse_entry != NULL)
|
if (sparse_entry != NULL)
|
||||||
write_entry(ar, sparse_entry);
|
write_entry(ar, sparse_entry);
|
||||||
|
if (buf)
|
||||||
|
free(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
Loading…
x
Reference in New Issue
Block a user