Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
SUSE:SLE-12:Update
file.20727
file-91a5efbb98.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File file-91a5efbb98.patch of Package file.20727
From 91a5efbb98579b98c27dbaed01694e4bda3edc9e Mon Sep 17 00:00:00 2001 From: Christos Zoulas <christos@zoulas.com> Date: Tue, 9 Jun 2015 22:17:52 +0000 Subject: [PATCH] - bytecnt needs to be adjusted by offset - always return true from mget() regardless if match() matched. Fixes mime printing where we stopped matching the use magic because match return 0, since if (print) *returnval = 1; did not execute for mime. --- src/softmagic.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) --- src/softmagic.c +++ src/softmagic.c 2017-10-23 13:13:15.012765627 +0000 @@ -1089,6 +1089,8 @@ mcopy(struct magic_set *ms, union VALUET if (indir == 0) { switch (type) { case FILE_SEARCH: + if (offset > nbytes) + offset = CAST(uint32_t, nbytes); ms->search.s = RCAST(const char *, s) + offset; ms->search.s_len = nbytes - offset; ms->search.offset = offset; @@ -1102,7 +1104,7 @@ mcopy(struct magic_set *ms, union VALUET const char *end; size_t lines, linecnt, bytecnt; - if (s == NULL) { + if (s == NULL || nbytes < offset) { ms->search.s_len = 0; ms->search.s = NULL; return 0; @@ -1116,13 +1118,13 @@ mcopy(struct magic_set *ms, union VALUET bytecnt = m->str_range; } - if (bytecnt == 0) + if (bytecnt == 0 || bytecnt > nbytes - offset) + bytecnt = nbytes - offset; + if (bytecnt > 8192) bytecnt = 8192; - if (bytecnt > nbytes) - bytecnt = nbytes; buf = RCAST(const char *, s) + offset; - end = last = RCAST(const char *, s) + bytecnt; + end = last = RCAST(const char *, s) + bytecnt + offset; /* mget() guarantees buf <= last */ for (lines = linecnt, b = buf; lines && b < end && ((b = CAST(const char *, @@ -1131,7 +1133,7 @@ mcopy(struct magic_set *ms, union VALUET memchr(c, '\r', CAST(size_t, (end - c)))))); lines--, b++) { last = b; - if (b[0] == '\r' && b[1] == '\n') + if (b < end - 1 && b[0] == '\r' && b[1] == '\n') b++; } if (lines) @@ -1164,7 +1166,8 @@ mcopy(struct magic_set *ms, union VALUET if (*dst == '\0') { if (type == FILE_BESTRING16 ? *(src - 1) != '\0' : - *(src + 1) != '\0') + ((src + 1 < esrc) && + *(src + 1) != '\0')) *dst = ' '; } } @@ -1721,7 +1724,7 @@ mget(struct magic_set *ms, const unsigne printed_something, need_separator, returnval); if (rv != 1) *need_separator = oneed_separator; - return rv; + return 1; case FILE_NAME: if (file_printf(ms, "%s", m->desc) == -1)
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor