lib/plist_fetch.c: don't abort on ARCHIVE_WARN in xbps_archive_fetch_file_into_fd

Prior to this change, xbps-query --cat would abort if the entry file
name would contain non ascii characters as it returns ARCHIVE_WARN
when failing to use iconv to the users character encoding without
having locales initialized.
Other places in xbps already ignore ARCHIVE_WARN.
This commit is contained in:
Duncan Overbruck 2021-12-19 15:45:07 +01:00
parent 760d14576f
commit 3939d9aeb5
No known key found for this signature in database
GPG Key ID: 335C1D17EC3D6E35

View File

@ -238,18 +238,35 @@ xbps_archive_fetch_file_into_fd(const char *url, const char *fname, int fd)
if ((a = open_archive(url)) == NULL)
return EINVAL;
while ((archive_read_next_header(a, &entry)) == ARCHIVE_OK) {
for (;;) {
const char *bfile;
rv = archive_read_next_header(a, &entry);
if (rv == ARCHIVE_EOF) {
rv = 0;
break;
}
if (rv == ARCHIVE_FATAL) {
const char *error = archive_error_string(a);
if (error != NULL) {
xbps_error_printf(
"Reading archive entry from: %s: %s\n",
url, error);
} else {
xbps_error_printf(
"Reading archive entry from: %s: %s\n",
url, strerror(archive_errno(a)));
}
rv = archive_errno(a);
break;
}
bfile = archive_entry_pathname(entry);
if (bfile[0] == '.')
bfile++; /* skip first dot */
if (strcmp(bfile, fname) == 0) {
rv = archive_read_data_into_fd(a, fd);
if (rv != 0)
if (rv != ARCHIVE_OK)
rv = archive_errno(a);
break;
}
archive_read_data_skip(a);