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