mirror of
https://github.com/FDOS/kernel.git
synced 2025-07-28 00:04:11 +02:00
From Tom Ehlert, gracefully error when attempting to write past 4GB instead of wrapping and causing corruption.
This commit is contained in:
parent
42a006b964
commit
de08998969
@ -1243,6 +1243,18 @@ long rwblock(COUNT fd, VOID FAR * buffer, UCOUNT count, int mode)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* prevent overwriting beginning of file when write exceeds 4GB,
|
||||||
|
i.e. when overflow of offset occurs, return error on write */
|
||||||
|
if (fnp->f_offset + count < fnp->f_offset) /* unsigned overflow */
|
||||||
|
{
|
||||||
|
if (mode == XFR_WRITE)
|
||||||
|
{
|
||||||
|
/* can't extend beyond 4G so return '0 byte written, DISK_FULL */
|
||||||
|
return DE_HNDLDSKFULL;
|
||||||
|
}
|
||||||
|
/* else XFR_READ should end automatically at EOF */
|
||||||
|
}
|
||||||
|
|
||||||
/* The variable secsize will be used later. */
|
/* The variable secsize will be used later. */
|
||||||
secsize = fnp->f_dpb->dpb_secsize;
|
secsize = fnp->f_dpb->dpb_secsize;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user