File tree Expand file tree Collapse file tree 1 file changed +19
-11
lines changed Expand file tree Collapse file tree 1 file changed +19
-11
lines changed Original file line number Diff line number Diff line change @@ -1587,23 +1587,31 @@ static PAL_ERROR MAPGrowLocalFile( INT UnixFD, off_t NewSize )
15871587 }
15881588
15891589 memset ( buf, 0 , BUFFER_SIZE );
1590-
1591- for ( x = 0 ; x < NewSize - OrigSize - BUFFER_SIZE; x += BUFFER_SIZE )
1590+ if (NewSize - OrigSize - BUFFER_SIZE >= 0 && BUFFER_SIZE > 0 )
15921591 {
1593- if ( write ( UnixFD, (LPVOID)buf, BUFFER_SIZE ) == - 1 )
1592+ for ( x = 0 ; x < NewSize - OrigSize - BUFFER_SIZE; x += BUFFER_SIZE )
15941593 {
1595- ERROR ( " Unable to grow the file. Reason=%s\n " , strerror ( errno ) );
1596- if ((errno == ENOSPC) || (errno == EDQUOT))
1594+ if ( write ( UnixFD, (LPVOID)buf, BUFFER_SIZE ) == -1 )
15971595 {
1598- palError = ERROR_DISK_FULL;
1599- }
1600- else
1601- {
1602- palError = ERROR_INTERNAL_ERROR;
1596+ ERROR ( " Unable to grow the file. Reason=%s\n " , strerror ( errno ) );
1597+ if ((errno == ENOSPC) || (errno == EDQUOT))
1598+ {
1599+ palError = ERROR_DISK_FULL;
1600+ }
1601+ else
1602+ {
1603+ palError = ERROR_INTERNAL_ERROR;
1604+ }
1605+ goto done;
16031606 }
1604- goto done;
16051607 }
16061608 }
1609+ else
1610+ {
1611+ // This will be an infinite loop because it did not pass the check.
1612+ palError = ERROR_INTERNAL_ERROR;
1613+ goto done;
1614+ }
16071615 /* Catch any left overs. */
16081616 if ( x != NewSize )
16091617 {
You can’t perform that action at this time.
0 commit comments