.
OBS-URL: https://build.opensuse.org/package/show/Base:System/file?expand=0&rev=129
This commit is contained in:
parent
22277e3619
commit
876a3058ba
130
file-5.26-downgrade_DER.patch
Normal file
130
file-5.26-downgrade_DER.patch
Normal file
@ -0,0 +1,130 @@
|
||||
From 20c59ad54afc7427ea680f84c8ee5a576ba54b08 Mon Sep 17 00:00:00 2001
|
||||
From: Christos Zoulas <christos@zoulas.com>
|
||||
Date: Mon, 18 Apr 2016 15:10:34 +0000
|
||||
Subject: [PATCH] Downgrade DER comparison and offset lookup failures to be
|
||||
handled as match failures.
|
||||
|
||||
---
|
||||
softmagic.c | 58 +++++++++++++++++++++++++++++++++++++++-------------------
|
||||
1 file changed, 39 insertions(+), 19 deletions(-)
|
||||
|
||||
diff --git src/softmagic.c src/softmagic.c
|
||||
index 14a8bc5..5b5f0f9 100644
|
||||
--- src/softmagic.c
|
||||
+++ src/softmagic.c
|
||||
@@ -186,11 +186,11 @@ match(struct magic_set *ms, struct magic *magic, uint32_t nmagic,
|
||||
((text && (m->str_flags & FLT) == STRING_BINTEST) ||
|
||||
(!text && (m->str_flags & FLT) == STRING_TEXTTEST))) ||
|
||||
(m->flag & mode) != mode) {
|
||||
+flush:
|
||||
/* Skip sub-tests */
|
||||
- while (magindex + 1 < nmagic &&
|
||||
- magic[magindex + 1].cont_level != 0 &&
|
||||
- ++magindex)
|
||||
- continue;
|
||||
+ while (magindex < nmagic - 1 &&
|
||||
+ magic[magindex + 1].cont_level != 0)
|
||||
+ magindex++;
|
||||
continue; /* Skip to next top-level test*/
|
||||
}
|
||||
|
||||
@@ -227,10 +227,7 @@ match(struct magic_set *ms, struct magic *magic, uint32_t nmagic,
|
||||
* main entry didn't match,
|
||||
* flush its continuations
|
||||
*/
|
||||
- while (magindex < nmagic - 1 &&
|
||||
- magic[magindex + 1].cont_level != 0)
|
||||
- magindex++;
|
||||
- continue;
|
||||
+ goto flush;
|
||||
}
|
||||
|
||||
if ((e = handle_annotation(ms, m)) != 0) {
|
||||
@@ -255,8 +252,14 @@ match(struct magic_set *ms, struct magic *magic, uint32_t nmagic,
|
||||
if (print && mprint(ms, m) == -1)
|
||||
return -1;
|
||||
|
||||
- if (moffset(ms, m, nbytes, &ms->c.li[cont_level].off) == -1)
|
||||
+ switch (moffset(ms, m, nbytes, &ms->c.li[cont_level].off)) {
|
||||
+ case -1:
|
||||
return -1;
|
||||
+ case 0:
|
||||
+ goto flush;
|
||||
+ default:
|
||||
+ break;
|
||||
+ }
|
||||
|
||||
/* and any continuations that match */
|
||||
if (file_check_mem(ms, ++cont_level) == -1)
|
||||
@@ -362,9 +365,16 @@ match(struct magic_set *ms, struct magic *magic, uint32_t nmagic,
|
||||
if (print && mprint(ms, m) == -1)
|
||||
return -1;
|
||||
|
||||
- if (moffset(ms, m, nbytes,
|
||||
- &ms->c.li[cont_level].off) == -1)
|
||||
+ switch (moffset(ms, m, nbytes,
|
||||
+ &ms->c.li[cont_level].off)) {
|
||||
+ case -1:
|
||||
return -1;
|
||||
+ case 0:
|
||||
+ flush = 1;
|
||||
+ break;
|
||||
+ default:
|
||||
+ break;
|
||||
+ }
|
||||
|
||||
if (*m->desc)
|
||||
*need_separator = 1;
|
||||
@@ -813,9 +823,13 @@ moffset(struct magic_set *ms, struct magic *m, size_t nbytes, int32_t *op)
|
||||
case FILE_DER:
|
||||
{
|
||||
o = der_offs(ms, m, nbytes);
|
||||
- if (o == -1) {
|
||||
- file_error(ms, 0, "EOF computing DER offset");
|
||||
- return -1;
|
||||
+ if (o == -1 || (size_t)o > nbytes) {
|
||||
+ if ((ms->flags & MAGIC_DEBUG) != 0) {
|
||||
+ (void)fprintf(stderr,
|
||||
+ "Bad DER offset %d nbytes=%zu",
|
||||
+ o, nbytes);
|
||||
+ }
|
||||
+ return 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -825,12 +839,13 @@ moffset(struct magic_set *ms, struct magic *m, size_t nbytes, int32_t *op)
|
||||
break;
|
||||
}
|
||||
|
||||
- if ((size_t)o >= nbytes) {
|
||||
- file_error(ms, 0, "Offset out of range");
|
||||
+ if ((size_t)o > nbytes) {
|
||||
+ file_error(ms, 0, "Offset out of range %zu > %zu",
|
||||
+ (size_t)o, nbytes);
|
||||
return -1;
|
||||
}
|
||||
*op = o;
|
||||
- return 0;
|
||||
+ return 1;
|
||||
}
|
||||
|
||||
private uint32_t
|
||||
@@ -2107,8 +2122,13 @@ magiccheck(struct magic_set *ms, struct magic *m)
|
||||
return 1;
|
||||
case FILE_DER:
|
||||
matched = der_cmp(ms, m);
|
||||
- if (matched == -1)
|
||||
- file_error(ms, 0, "EOF comparing DER entries");
|
||||
+ if (matched == -1) {
|
||||
+ if ((ms->flags & MAGIC_DEBUG) != 0) {
|
||||
+ (void) fprintf(stderr,
|
||||
+ "EOF comparing DER entries");
|
||||
+ }
|
||||
+ return 0;
|
||||
+ }
|
||||
return matched;
|
||||
default:
|
||||
file_magerror(ms, "invalid type %d in magiccheck()", m->type);
|
||||
--
|
||||
2.6.6
|
||||
|
@ -1,3 +1,9 @@
|
||||
-------------------------------------------------------------------
|
||||
Tue Apr 19 09:35:28 UTC 2016 - werner@suse.de
|
||||
|
||||
- Add upstream patch file-5.26-downgrade_DER.patch
|
||||
to fix DER error messages as well oas offset handling
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Mon Apr 18 12:13:33 UTC 2016 - werner@suse.de
|
||||
|
||||
|
@ -64,6 +64,7 @@ Patch35: file-5.24-nitpick.dif
|
||||
Patch36: file-5.15-clear-invalid.patch
|
||||
Patch37: file-secure_getenv.patch
|
||||
Patch38: file-5.26-version.patch
|
||||
Patch39: file-5.26-downgrade_DER.patch
|
||||
BuildRoot: %{_tmppath}/%{name}-%{version}-build
|
||||
%global _sysconfdir /etc
|
||||
%global _miscdir %{_datadir}/misc
|
||||
@ -127,6 +128,7 @@ to develop applications that require the magic "file" interface.
|
||||
%patch36 -p1 -b .clear
|
||||
%patch37 -p1 -b .getenv
|
||||
%patch38 -p1 -b .php
|
||||
%patch39 -p0 -b .DER
|
||||
%patch -b .0
|
||||
test -s src/magic.h.in || cp -p src/magic.h src/magic.h.in
|
||||
rm -fv src/magic.h
|
||||
|
Loading…
Reference in New Issue
Block a user