[wd2010] properly constrain R/W ops based on end sector

Wed, 16 Jan 2013 00:38:13 +0000

author
Philip Pemberton <philpem@philpem.me.uk>
date
Wed, 16 Jan 2013 00:38:13 +0000
changeset 125
7fb4f58f620a
parent 124
ecaec4cfc644
child 126
d79a028161fd

[wd2010] properly constrain R/W ops based on end sector

src/wd2010.c file | annotate | diff | revisions
     1.1 --- a/src/wd2010.c	Wed Jan 16 00:36:51 2013 +0000
     1.2 +++ b/src/wd2010.c	Wed Jan 16 00:38:13 2013 +0000
     1.3 @@ -346,10 +346,12 @@
     1.4  							// Read Sector
     1.5  
     1.6  							// Check to see if the cyl, hd and sec are valid
     1.7 -							if ((ctx->track > (ctx->geom_tracks-1)) || (ctx->head > (ctx->geom_heads-1)) || (ctx->sector > ctx->geom_spt - 1)) {
     1.8 -								LOG("*** WD2010 ALERT: CHS parameter limit exceeded! CHS=%d:%d:%d, maxCHS=%d:%d:%d",
     1.9 +							if ((ctx->track > (ctx->geom_tracks-1)) || (ctx->head > (ctx->geom_heads-1)) || ((ctx->sector + ctx->sector_count - 1) > ctx->geom_spt-1)) {
    1.10 +								LOG("*** WD2010 ALERT: CHS parameter limit exceeded! CHS=%d:%d:%d, nSecs=%d, endSec=%d maxCHS=%d:%d:%d",
    1.11  										ctx->track, ctx->head, ctx->sector,
    1.12 -										ctx->geom_tracks-1, ctx->geom_heads-1, ctx->geom_spt-1);
    1.13 +										ctx->sector_count,
    1.14 +										ctx->sector + ctx->sector_count - 1,
    1.15 +										ctx->geom_tracks-1, ctx->geom_heads-1, ctx->geom_spt);
    1.16  								// CHS parameters exceed limits
    1.17  								ctx->status = SR_ERROR;
    1.18  								ctx->error_reg = ER_ID_NOT_FOUND;
    1.19 @@ -395,9 +397,11 @@
    1.20  							// Write Sector
    1.21  
    1.22  							// Check to see if the cyl, hd and sec are valid
    1.23 -							if ((ctx->track > (ctx->geom_tracks-1)) || (ctx->head > (ctx->geom_heads-1)) || (ctx->sector > ctx->geom_spt-1)) {
    1.24 -								LOG("*** WD2010 ALERT: CHS parameter limit exceeded! CHS=%d:%d:%d, maxCHS=%d:%d:%d",
    1.25 +							if ((ctx->track > (ctx->geom_tracks-1)) || (ctx->head > (ctx->geom_heads-1)) || ((ctx->sector + ctx->sector_count - 1) > ctx->geom_spt-1)) {
    1.26 +								LOG("*** WD2010 ALERT: CHS parameter limit exceeded! CHS=%d:%d:%d, nSecs=%d, endSec=%d maxCHS=%d:%d:%d",
    1.27  										ctx->track, ctx->head, ctx->sector,
    1.28 +										ctx->sector_count,
    1.29 +										ctx->sector + ctx->sector_count - 1,
    1.30  										ctx->geom_tracks-1, ctx->geom_heads-1, ctx->geom_spt);
    1.31  								// CHS parameters exceed limits
    1.32  								ctx->status = SR_ERROR;