make sure argument to open is terminated by a 0-byte

This commit is contained in:
ceriel 1987-09-08 15:35:34 +00:00
parent 1ce6abf3de
commit 286acd933c

View file

@ -32,12 +32,17 @@ IMPLEMENTATION MODULE PascalIO;
head: Text; head: Text;
PROCEDURE Reset(VAR InputText: Text; Filename: ARRAY OF CHAR); PROCEDURE Reset(VAR InputText: Text; Filename: ARRAY OF CHAR);
VAR i: CARDINAL;
BEGIN BEGIN
doclose(InputText); doclose(InputText);
getstruct(InputText); getstruct(InputText);
WITH InputText^ DO WITH InputText^ DO
eof := FALSE; eof := FALSE;
fildes := Unix.open(ADR(Filename), 0); FOR i := 0 TO HIGH(Filename) DO
buf[i+1] := Filename[i];
END;
buf[HIGH(Filename)+2] := 0C;
fildes := Unix.open(ADR(buf), 0);
IF fildes < 0 THEN IF fildes < 0 THEN
Traps.Message("could not open input file"); Traps.Message("could not open input file");
HALT; HALT;
@ -50,12 +55,17 @@ IMPLEMENTATION MODULE PascalIO;
END Reset; END Reset;
PROCEDURE Rewrite(VAR OutputText: Text; Filename: ARRAY OF CHAR); PROCEDURE Rewrite(VAR OutputText: Text; Filename: ARRAY OF CHAR);
VAR i: CARDINAL;
BEGIN BEGIN
doclose(OutputText); doclose(OutputText);
getstruct(OutputText); getstruct(OutputText);
WITH OutputText^ DO WITH OutputText^ DO
eof := FALSE; eof := FALSE;
fildes := Unix.creat(ADR(Filename), 666B); FOR i := 0 TO HIGH(Filename) DO
buf[i+1] := Filename[i];
END;
buf[HIGH(Filename)+2] := 0C;
fildes := Unix.creat(ADR(buf), 666B);
IF fildes < 0 THEN IF fildes < 0 THEN
Traps.Message("could not open output file"); Traps.Message("could not open output file");
HALT; HALT;