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:
		| @@ -238,18 +238,35 @@ xbps_archive_fetch_file_into_fd(const char *url, const char *fname, int fd) | |||||||
| 	if ((a = open_archive(url)) == NULL) | 	if ((a = open_archive(url)) == NULL) | ||||||
| 		return EINVAL; | 		return EINVAL; | ||||||
|  |  | ||||||
| 	while ((archive_read_next_header(a, &entry)) == ARCHIVE_OK) { | 	for (;;) { | ||||||
| 		const char *bfile; | 		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); | 		bfile = archive_entry_pathname(entry); | ||||||
| 		if (bfile[0] == '.') | 		if (bfile[0] == '.') | ||||||
| 			bfile++; /* skip first dot */ | 			bfile++; /* skip first dot */ | ||||||
|  |  | ||||||
| 		if (strcmp(bfile, fname) == 0) { | 		if (strcmp(bfile, fname) == 0) { | ||||||
| 			rv = archive_read_data_into_fd(a, fd); | 			rv = archive_read_data_into_fd(a, fd); | ||||||
| 			if (rv != 0) | 			if (rv != ARCHIVE_OK) | ||||||
| 				rv = archive_errno(a); | 				rv = archive_errno(a); | ||||||
|  |  | ||||||
| 			break; | 			break; | ||||||
| 		} | 		} | ||||||
| 		archive_read_data_skip(a); | 		archive_read_data_skip(a); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user