Skip to content

Commit

Permalink
Fix incorrect bounds check for sector count. (Francisco Alonso and Ja…
Browse files Browse the repository at this point in the history
…n Kaluza

at RedHat)
  • Loading branch information
zoulasc committed Jun 4, 2014
1 parent 6a193d3 commit 40bade8
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/cdf.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
#include "file.h"

#ifndef lint
FILE_RCSID("@(#)$File: cdf.c,v 1.59 2014/05/14 23:22:48 christos Exp $")
FILE_RCSID("@(#)$File: cdf.c,v 1.60 2014/05/21 13:04:38 christos Exp $")
#endif

#include <assert.h>
Expand Down Expand Up @@ -455,7 +455,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 @@ -465,8 +466,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 40bade8

Please sign in to comment.