summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/opkg/opkg/0001-opkg_archive-add-support-for-empty-compressed-files.patch
blob: dabd196d2c8e63f5b87884af117b0a8649fea0ef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
From bd32bb8646459508bb0b0ce54a14bd6fe0e19b75 Mon Sep 17 00:00:00 2001
From: Alejandro del Castillo <alejandro.delcastillo@ni.com>
Date: Thu, 27 Aug 2015 15:52:16 -0500
Subject: [PATCH] opkg_archive: add support for empty compressed files

Regression from 0.2.x: opkg used to support empty Package.gz files.

Signed-off-by: Alejandro del Castillo <alejandro.delcastillo@ni.com>

Upstream-Status: Accepted
---
 libopkg/opkg_archive.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/libopkg/opkg_archive.c b/libopkg/opkg_archive.c
index be903e4..7e91e48 100644
--- a/libopkg/opkg_archive.c
+++ b/libopkg/opkg_archive.c
@@ -121,6 +121,9 @@ static int copy_to_stream(struct archive *a, FILE * stream)
     int eof;
     size_t len = EXTRACT_BUFFER_LEN;
 
+    if (archive_format(a) == ARCHIVE_FORMAT_EMPTY)
+        return 0;
+
     buffer = xmalloc(len);
 
     while (1) {
@@ -654,6 +657,13 @@ static struct archive *open_compressed_file(const char *filename)
         goto err_cleanup;
     }
 
+    r = archive_read_support_format_empty(ar);
+    if (r != ARCHIVE_OK) {
+        opkg_msg(ERROR, "Empty format not supported: %s\n",
+                 archive_error_string(ar));
+        goto err_cleanup;
+    }
+
     /* Open input file and prepare for reading. */
     r = archive_read_open_filename(ar, filename, EXTRACT_BUFFER_LEN);
     if (r != ARCHIVE_OK) {
@@ -723,6 +733,7 @@ struct opkg_ar *ar_open_compressed_file(const char *filename)
 {
     struct opkg_ar *ar;
     struct archive_entry *entry;
+    int eof;
 
     ar = (struct opkg_ar *)xmalloc(sizeof(struct opkg_ar));
 
@@ -737,8 +748,8 @@ struct opkg_ar *ar_open_compressed_file(const char *filename)
      * header. We skip over this header here so that the caller doesn't need
      * to know about it.
      */
-    entry = read_header(ar->ar, NULL);
-    if (!entry)
+    entry = read_header(ar->ar, &eof);
+    if (!entry && !eof)
         goto err_cleanup;
 
     return ar;
-- 
1.9.1