Give an error if file names or command-line parameters are too long.

The source file name, keep name, NAMES= string, and cc= string are all restricted to 255 characters, but these limits were not previously enforced, and exceeding them could lead to strange behavior.
This commit is contained in:
Stephen Heumann 2022-02-12 15:42:15 -06:00
parent bd811559d6
commit 06e17cd8f5
3 changed files with 20 additions and 7 deletions

24
CC.pas
View File

@ -36,7 +36,7 @@ begin {cc}
{make sure we quit with restart set} {make sure we quit with restart set}
SystemQuitFlags($4000); SystemQuitFlags($4000);
{get the command line info} {initialize file names and parameter strings}
includeFileGS.maxSize := maxPath+4; includeFileGS.maxSize := maxPath+4;
includeFileGS.theString.size := 0; includeFileGS.theString.size := 0;
for i := 1 to maxPath do for i := 1 to maxPath do
@ -44,6 +44,14 @@ for i := 1 to maxPath do
outFileGS := includeFileGS; outFileGS := includeFileGS;
partialFileGS := includeFileGS; partialFileGS := includeFileGS;
infoStringGS := includeFileGS; infoStringGS := includeFileGS;
{check the version number}
vDCBGS.pCount := 1;
VersionGS(vDCBGS);
if (ToolError <> 0) or (vDCBGS.version[1] < '2') then
TermError(10);
{get the command line info}
with liDCBGS do begin with liDCBGS do begin
pCount := 11; pCount := 11;
sFile := @includeFileGS; sFile := @includeFileGS;
@ -52,6 +60,14 @@ with liDCBGS do begin
iString := @infoStringGS; iString := @infoStringGS;
end; {with} end; {with}
GetLInfoGS(liDCBGS); GetLInfoGS(liDCBGS);
if ToolError <> 0 then begin {check for buffTooSmall errors}
includeFileGS.theString.size := 0;
outFileGS.theString.size := 0;
partialFileGS.theString.size := 0;
infoStringGS.theString.size := 0;
enterEditor := false;
TermError(13);
end; {if}
sourceFileGS := includeFileGS; sourceFileGS := includeFileGS;
doingPartial := partialFileGS.theString.size <> 0; doingPartial := partialFileGS.theString.size <> 0;
with liDCBGS do begin with liDCBGS do begin
@ -70,12 +86,6 @@ with liDCBGS do begin
if list then {we don't need both...} if list then {we don't need both...}
progress := false; progress := false;
{check the version number}
vDCBGS.pCount := 1;
VersionGS(vDCBGS);
if vDCBGS.version[1] < '2' then
TermError(10);
{write the header} {write the header}
if list or progress then begin if list or progress then begin
writeln('ORCA/C ', versionStr); writeln('ORCA/C ', versionStr);

View File

@ -999,6 +999,7 @@ case errnum of {print the error}
10: msg := 'ORCA/C requires version 2.0 or later of the shell'; 10: msg := 'ORCA/C requires version 2.0 or later of the shell';
11: msg := 'The program is too large to compile to memory -- use Compile to Disk'; 11: msg := 'The program is too large to compile to memory -- use Compile to Disk';
12: msg := 'Invalid sym file detected. Re-run ORCA/C to proceed.'; 12: msg := 'Invalid sym file detected. Re-run ORCA/C to proceed.';
13: msg := 'file name or command-line parameter is too long';
otherwise: begin otherwise: begin
msg := ''; msg := '';
Error(57); Error(57);

2
MM.pas
View File

@ -233,6 +233,8 @@ procedure MMQuit;
begin {MMQuit} begin {MMQuit}
DisposeAll(globalID); DisposeAll(globalID);
DisposeAll(localID); DisposeAll(localID);
globalID := 0; {do not use old IDs after restart}
localID := 0;
end; {MMQuit} end; {MMQuit}
end. end.