Skip to content

Commit

Permalink
Bug #67412 fileinfo: cdf_count_chain insufficient boundary check
Browse files Browse the repository at this point in the history
  • Loading branch information
remicollet authored and smalyshev committed Jul 18, 2014
1 parent 8d1d038 commit 892def5
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions ext/fileinfo/libmagic/cdf.c
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,8 @@ size_t
cdf_count_chain(const cdf_sat_t *sat, cdf_secid_t sid, size_t size)
{
size_t i, j;
cdf_secid_t maxsector = (cdf_secid_t)(sat->sat_len * size);
cdf_secid_t maxsector = (cdf_secid_t)((sat->sat_len * size)
/ sizeof(maxsector));

DPRINTF(("Chain:"));
for (j = i = 0; sid >= 0; i++, j++) {
Expand All @@ -480,8 +481,8 @@ cdf_count_chain(const cdf_sat_t *sat, cdf_secid_t sid, size_t size)
errno = EFTYPE;
return (size_t)-1;
}
if (sid > maxsector) {
DPRINTF(("Sector %d > %d\n", sid, maxsector));
if (sid >= maxsector) {
DPRINTF(("Sector %d >= %d\n", sid, maxsector));
errno = EFTYPE;
return (size_t)-1;
}
Expand Down

0 comments on commit 892def5

Please sign in to comment.