Mercurial > yaffs-ecoscentric
changeset 147:5141f90de139 Pre-retirement-changes
Bounds check on ecc correction
| author | charles |
|---|---|
| date | Thu, 14 Sep 2006 23:02:46 +0100 |
| parents | c293aabe14d0 |
| children | 1d8892b579f5 |
| files | yaffs_ecc.c |
| diffstat | 1 files changed, 5 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/yaffs_ecc.c +++ b/yaffs_ecc.c @@ -295,7 +295,8 @@ int yaffs_ECCCorrectOther(unsigned char if ((cDelta | lDelta | lDeltaPrime) == 0) return 0; /* no error */ - if (lDelta == ~lDeltaPrime && (((cDelta ^ (cDelta >> 1)) & 0x15) == 0x15)) + if (lDelta == ~lDeltaPrime && + (((cDelta ^ (cDelta >> 1)) & 0x15) == 0x15)) { /* Single bit (recoverable) error in data */ @@ -308,6 +309,9 @@ int yaffs_ECCCorrectOther(unsigned char if (cDelta & 0x02) bit |= 0x01; + if(lDelta >= nBytes) + return -1; + data[lDelta] ^= (1 << bit); return 1; /* corrected */
