summaryrefslogtreecommitdiff
path: root/sys-apps/file/files/file-5.26-compress-2.patch
blob: d27656f7fec8cabff712929b75dc0511cb35f39e (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
65
66
67
68
69
70
71
72
73
http://mx.gw.com/pipermail/file/2016/001978.html

From 26879a2b5ec6880cb46b416880e520c628927abd Mon Sep 17 00:00:00 2001
From: Christos Zoulas <christos@zoulas.com>
Date: Tue, 19 Apr 2016 23:36:36 +0000
Subject: [PATCH] Restore part of previous logic, that breaks out of the
 uncompress loop if there was a compression match error or not. Separate the
 return values to avoid confusion.

---
 src/compress.c | 23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/src/compress.c b/src/compress.c
index 0ebc837..2a95f85 100644
--- a/src/compress.c
+++ b/src/compress.c
@@ -187,7 +187,7 @@ file_zmagic(struct magic_set *ms, int fd, const char *name,
 	size_t i, nsz;
 	char *rbuf;
 	file_pushbuf_t *pb;
-	int rv = 0;
+	int urv, prv, rv = 0;
 	int mime = ms->flags & MAGIC_MIME;
 #ifdef HAVE_SIGNAL_H
 	sig_t osigpipe;
@@ -214,26 +214,26 @@ file_zmagic(struct magic_set *ms, int fd, const char *name,
 		if (!zm)
 			continue;
 		nsz = nbytes;
-		rv = uncompressbuf(fd, ms->bytes_max, i, buf, &newbuf, &nsz);
+		urv = uncompressbuf(fd, ms->bytes_max, i, buf, &newbuf, &nsz);
 		DPRINTF("uncompressbuf = %d, %s, %zu\n", rv, (char *)newbuf,
 		    nsz);
-		switch (rv) {
+		switch (urv) {
 		case OKDATA:
 		case ERRDATA:
 			
 			ms->flags &= ~MAGIC_COMPRESS;
-			if (rv == ERRDATA)
-				rv = file_printf(ms, "%s ERROR: %s",
+			if (urv == ERRDATA)
+				prv = file_printf(ms, "%s ERROR: %s",
 				    methodname(i), newbuf);
 			else
-				rv = file_buffer(ms, -1, name, newbuf, nsz);
-			if (rv == -1)
+				prv = file_buffer(ms, -1, name, newbuf, nsz);
+			if (prv == -1)
 				goto error;
-			DPRINTF("rv = %d\n", rv);
+			rv = 1;
 			if ((ms->flags & MAGIC_COMPRESS_TRANSP) != 0)
-				break;
+				goto out;
 			if (mime != MAGIC_MIME && mime != 0)
-				break;
+				goto out;
 			if ((file_printf(ms,
 			    mime ? " compressed-encoding=" : " (")) == -1)
 				goto error;
@@ -261,6 +261,7 @@ file_zmagic(struct magic_set *ms, int fd, const char *name,
 			break;
 		}
 	}
+out:
 	DPRINTF("rv = %d\n", rv);
 
 #ifdef HAVE_SIGNAL_H
-- 
2.7.4