Skip to content

Commit 8d1d038

Browse files
remicolletsmalyshev
authored andcommitted
Fixed Bug #67411 fileinfo: cdf_check_stream_offset insufficient boundary check
Upstream: file/file@36fadd2 Conflicts: ext/fileinfo/libmagic/cdf.c
1 parent 6bd5a06 commit 8d1d038

File tree

1 file changed

+4
-2
lines changed
  • ext/fileinfo/libmagic

1 file changed

+4
-2
lines changed

ext/fileinfo/libmagic/cdf.c

+4-2
Original file line numberDiff line numberDiff line change
@@ -277,13 +277,15 @@ cdf_check_stream_offset(const cdf_stream_t *sst, const cdf_header_t *h,
277277
{
278278
const char *b = (const char *)sst->sst_tab;
279279
const char *e = ((const char *)p) + tail;
280+
size_t ss = sst->sst_dirlen < h->h_min_size_standard_stream ?
281+
CDF_SHORT_SEC_SIZE(h) : CDF_SEC_SIZE(h);
280282
(void)&line;
281-
if (e >= b && (size_t)(e - b) < CDF_SEC_SIZE(h) * sst->sst_len)
283+
if (e >= b && (size_t)(e - b) <= ss * sst->sst_len)
282284
return 0;
283285
DPRINTF(("%d: offset begin %p end %p %" SIZE_T_FORMAT "u"
284286
" >= %" SIZE_T_FORMAT "u [%" SIZE_T_FORMAT "u %"
285287
SIZE_T_FORMAT "u]\n", line, b, e, (size_t)(e - b),
286-
CDF_SEC_SIZE(h) * sst->sst_len, CDF_SEC_SIZE(h), sst->sst_len));
288+
ss * sst->sst_len, ss, sst->sst_len));
287289
errno = EFTYPE;
288290
return -1;
289291
}

0 commit comments

Comments
 (0)