mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-09-13 14:49:10 +02:00
* Fixed crash in DiskFree() and DiskSize() on Unices due to out of bound read of the DriveStr[] array in rare cases.
git-svn-id: trunk@39866 -
This commit is contained in:
parent
212eca24d1
commit
5e92e2d23f
@ -1134,7 +1134,7 @@ var
|
|||||||
fs : tstatfs;
|
fs : tstatfs;
|
||||||
Begin
|
Begin
|
||||||
if ((Drive in [Low(FixDriveStr)..High(FixDriveStr)]) and (not (fixdrivestr[Drive]=nil)) and (fpstatfs(StrPas(fixdrivestr[drive]),@fs)<>-1)) or
|
if ((Drive in [Low(FixDriveStr)..High(FixDriveStr)]) and (not (fixdrivestr[Drive]=nil)) and (fpstatfs(StrPas(fixdrivestr[drive]),@fs)<>-1)) or
|
||||||
((Drive <= High(drivestr)) and (not (drivestr[Drive]=nil)) and (fpstatfs(StrPas(drivestr[drive]),@fs)<>-1)) then
|
((Drive in [Low(DriveStr)..High(DriveStr)]) and (not (drivestr[Drive]=nil)) and (fpstatfs(StrPas(drivestr[drive]),@fs)<>-1)) then
|
||||||
Diskfree:=int64(fs.bavail)*int64(fs.bsize)
|
Diskfree:=int64(fs.bavail)*int64(fs.bsize)
|
||||||
else
|
else
|
||||||
Diskfree:=-1;
|
Diskfree:=-1;
|
||||||
@ -1147,7 +1147,7 @@ var
|
|||||||
fs : tstatfs;
|
fs : tstatfs;
|
||||||
Begin
|
Begin
|
||||||
if ((Drive in [Low(FixDriveStr)..High(FixDriveStr)]) and (not (fixdrivestr[Drive]=nil)) and (fpstatfs(StrPas(fixdrivestr[drive]),@fs)<>-1)) or
|
if ((Drive in [Low(FixDriveStr)..High(FixDriveStr)]) and (not (fixdrivestr[Drive]=nil)) and (fpstatfs(StrPas(fixdrivestr[drive]),@fs)<>-1)) or
|
||||||
((drive <= High(drivestr)) and (not (drivestr[Drive]=nil)) and (fpstatfs(StrPas(drivestr[drive]),@fs)<>-1)) then
|
((Drive in [Low(DriveStr)..High(DriveStr)]) and (not (drivestr[Drive]=nil)) and (fpstatfs(StrPas(drivestr[drive]),@fs)<>-1)) then
|
||||||
DiskSize:=int64(fs.blocks)*int64(fs.bsize)
|
DiskSize:=int64(fs.blocks)*int64(fs.bsize)
|
||||||
else
|
else
|
||||||
DiskSize:=-1;
|
DiskSize:=-1;
|
||||||
|
Loading…
Reference in New Issue
Block a user