From Tom Ehlert, gracefully error when attempting to write past 4GB instead of wrapping and causing corruption.

This commit is contained in:
Kenneth J Davis 2025-03-28 14:14:44 -04:00
parent 42a006b964
commit de08998969
No known key found for this signature in database
GPG Key ID: 59D5F216C38F11FD

View File

@ -1243,6 +1243,18 @@ long rwblock(COUNT fd, VOID FAR * buffer, UCOUNT count, int mode)
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. */
secsize = fnp->f_dpb->dpb_secsize;