|
|
d7e7c0 |
diff -urp file-5.33.orig/src/softmagic.c file-5.33/src/softmagic.c
|
|
|
d7e7c0 |
--- file-5.33.orig/src/softmagic.c 2020-12-14 12:26:50.286849841 -0500
|
|
|
d7e7c0 |
+++ file-5.33/src/softmagic.c 2020-12-14 12:35:52.679166211 -0500
|
|
|
d7e7c0 |
@@ -1748,7 +1748,8 @@ mget(struct magic_set *ms, struct magic
|
|
|
d7e7c0 |
}
|
|
|
d7e7c0 |
|
|
|
d7e7c0 |
private uint64_t
|
|
|
d7e7c0 |
-file_strncmp(const char *s1, const char *s2, size_t len, uint32_t flags)
|
|
|
d7e7c0 |
+file_strncmp(const char *s1, const char *s2, size_t len, size_t maxlen,
|
|
|
d7e7c0 |
+ uint32_t flags)
|
|
|
d7e7c0 |
{
|
|
|
d7e7c0 |
/*
|
|
|
d7e7c0 |
* Convert the source args to unsigned here so that (1) the
|
|
|
d7e7c0 |
@@ -1760,7 +1761,7 @@ file_strncmp(const char *s1, const char
|
|
|
d7e7c0 |
const unsigned char *b = (const unsigned char *)s2;
|
|
|
d7e7c0 |
uint32_t ws = flags & (STRING_COMPACT_WHITESPACE |
|
|
|
d7e7c0 |
STRING_COMPACT_OPTIONAL_WHITESPACE);
|
|
|
d7e7c0 |
- const unsigned char *eb = b + (ws ? strlen(s2) : len);
|
|
|
d7e7c0 |
+ const unsigned char *eb = b + (ws ? maxlen : len);
|
|
|
d7e7c0 |
uint64_t v;
|
|
|
d7e7c0 |
|
|
|
d7e7c0 |
/*
|
|
|
d7e7c0 |
@@ -1818,7 +1819,8 @@ file_strncmp(const char *s1, const char
|
|
|
d7e7c0 |
}
|
|
|
d7e7c0 |
|
|
|
d7e7c0 |
private uint64_t
|
|
|
d7e7c0 |
-file_strncmp16(const char *a, const char *b, size_t len, uint32_t flags)
|
|
|
d7e7c0 |
+file_strncmp16(const char *a, const char *b, size_t len, size_t maxlen,
|
|
|
d7e7c0 |
+ uint32_t flags)
|
|
|
d7e7c0 |
{
|
|
|
d7e7c0 |
/*
|
|
|
d7e7c0 |
* XXX - The 16-bit string compare probably needs to be done
|
|
|
d7e7c0 |
@@ -1826,7 +1828,7 @@ file_strncmp16(const char *a, const char
|
|
|
d7e7c0 |
* At the moment, I am unsure.
|
|
|
d7e7c0 |
*/
|
|
|
d7e7c0 |
flags = 0;
|
|
|
d7e7c0 |
- return file_strncmp(a, b, len, flags);
|
|
|
d7e7c0 |
+ return file_strncmp(a, b, len, maxlen, flags);
|
|
|
d7e7c0 |
}
|
|
|
d7e7c0 |
|
|
|
d7e7c0 |
private int
|
|
|
d7e7c0 |
@@ -1954,13 +1956,15 @@ magiccheck(struct magic_set *ms, struct
|
|
|
d7e7c0 |
case FILE_STRING:
|
|
|
d7e7c0 |
case FILE_PSTRING:
|
|
|
d7e7c0 |
l = 0;
|
|
|
d7e7c0 |
- v = file_strncmp(m->value.s, p->s, (size_t)m->vallen, m->str_flags);
|
|
|
d7e7c0 |
+ v = file_strncmp(m->value.s, p->s, (size_t)m->vallen,
|
|
|
d7e7c0 |
+ sizeof(p->s), m->str_flags);
|
|
|
d7e7c0 |
break;
|
|
|
d7e7c0 |
|
|
|
d7e7c0 |
case FILE_BESTRING16:
|
|
|
d7e7c0 |
case FILE_LESTRING16:
|
|
|
d7e7c0 |
l = 0;
|
|
|
d7e7c0 |
- v = file_strncmp16(m->value.s, p->s, (size_t)m->vallen, m->str_flags);
|
|
|
d7e7c0 |
+ v = file_strncmp16(m->value.s, p->s, (size_t)m->vallen,
|
|
|
d7e7c0 |
+ sizeof(p->s), m->str_flags);
|
|
|
d7e7c0 |
break;
|
|
|
d7e7c0 |
|
|
|
d7e7c0 |
case FILE_SEARCH: { /* search ms->search.s for the string m->value.s */
|
|
|
d7e7c0 |
@@ -1979,7 +1983,7 @@ magiccheck(struct magic_set *ms, struct
|
|
|
d7e7c0 |
return 0;
|
|
|
d7e7c0 |
|
|
|
d7e7c0 |
v = file_strncmp(m->value.s, ms->search.s + idx, slen,
|
|
|
d7e7c0 |
- m->str_flags);
|
|
|
d7e7c0 |
+ ms->search.s_len - idx, m->str_flags);
|
|
|
d7e7c0 |
if (v == 0) { /* found match */
|
|
|
d7e7c0 |
ms->search.offset += idx;
|
|
|
d7e7c0 |
ms->search.rm_len = ms->search.s_len - idx;
|