blob: dabd196d2c8e63f5b87884af117b0a8649fea0ef [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001From bd32bb8646459508bb0b0ce54a14bd6fe0e19b75 Mon Sep 17 00:00:00 2001
2From: Alejandro del Castillo <alejandro.delcastillo@ni.com>
3Date: Thu, 27 Aug 2015 15:52:16 -0500
4Subject: [PATCH] opkg_archive: add support for empty compressed files
5
6Regression from 0.2.x: opkg used to support empty Package.gz files.
7
8Signed-off-by: Alejandro del Castillo <alejandro.delcastillo@ni.com>
9
10Upstream-Status: Accepted
11---
12 libopkg/opkg_archive.c | 15 +++++++++++++--
13 1 file changed, 13 insertions(+), 2 deletions(-)
14
15diff --git a/libopkg/opkg_archive.c b/libopkg/opkg_archive.c
16index be903e4..7e91e48 100644
17--- a/libopkg/opkg_archive.c
18+++ b/libopkg/opkg_archive.c
19@@ -121,6 +121,9 @@ static int copy_to_stream(struct archive *a, FILE * stream)
20 int eof;
21 size_t len = EXTRACT_BUFFER_LEN;
22
23+ if (archive_format(a) == ARCHIVE_FORMAT_EMPTY)
24+ return 0;
25+
26 buffer = xmalloc(len);
27
28 while (1) {
29@@ -654,6 +657,13 @@ static struct archive *open_compressed_file(const char *filename)
30 goto err_cleanup;
31 }
32
33+ r = archive_read_support_format_empty(ar);
34+ if (r != ARCHIVE_OK) {
35+ opkg_msg(ERROR, "Empty format not supported: %s\n",
36+ archive_error_string(ar));
37+ goto err_cleanup;
38+ }
39+
40 /* Open input file and prepare for reading. */
41 r = archive_read_open_filename(ar, filename, EXTRACT_BUFFER_LEN);
42 if (r != ARCHIVE_OK) {
43@@ -723,6 +733,7 @@ struct opkg_ar *ar_open_compressed_file(const char *filename)
44 {
45 struct opkg_ar *ar;
46 struct archive_entry *entry;
47+ int eof;
48
49 ar = (struct opkg_ar *)xmalloc(sizeof(struct opkg_ar));
50
51@@ -737,8 +748,8 @@ struct opkg_ar *ar_open_compressed_file(const char *filename)
52 * header. We skip over this header here so that the caller doesn't need
53 * to know about it.
54 */
55- entry = read_header(ar->ar, NULL);
56- if (!entry)
57+ entry = read_header(ar->ar, &eof);
58+ if (!entry && !eof)
59 goto err_cleanup;
60
61 return ar;
62--
631.9.1
64