[Info-vax] Any stronger versions of the LMF planned ?, was: Re: LMF Licence Generator Code

Arne Vajhøj arne at vajhoej.dk
Fri Aug 20 10:37:02 EDT 2021


On 8/20/2021 9:38 AM, Jan-Erik Söderholm wrote:
> Den 2021-08-20 kl. 15:20, skrev Arne Vajhøj:
>> I will claim that the determining factor is neither fixed length or
>> null termination - the determining factor is whether length are
>> always present together with the string.
>>
>> In VMS calling standard: that strings are passed by descriptor
>> instead of by reference.
>>
>> Fortran, Cobol, Pascal fixed length strings are passed
>> by descriptor. The language RTL can handle things.
>>
>> Pascal, Basic variable length strings are passed by descriptor.
>> The language RTL can handle things.
>>
>> C "strings" (char array using null termination) are passed by
>> reference. And unless length is passed as a separate argument
>> and programmer explicit use it properly then bad things can happen,
>>
>> So there are no difference in definitions for normal code.
>>
>> The difference only becomes relevant when changing the
>> default pass by descriptor to pass by reference. Then
>> a non-C non-null-terminated string becomes dangerous
>> as well.
> 
> Still, it is very hard to "overwrite" a PIC X(nnn) variable using
> pure Cobol code.

Yes.

Passing strings by reference is probably mostly a calling
C or Macro-32 problem.

I know that Pascal only allows it for external routines.

Example:

$ type s1.pas
program s1(input, output);

procedure gets(var s : packed array [$u1..$u2:integer] of char);

begin
     readln(s);
end;

var
     s : packed array [1..32] of char;

begin
     s := '                                ';
     gets(s);
     writeln(s);
end.
$ pas s1
$ link s1
$ run s1
1234567890
1234567890
$ run s1
12345678901234567890123456789012345678901234567890123456789012345678901234567890
12345678901234567890123456789012
$ type s2.pas
program s2(input, output);

[external('decc$gets')]
procedure gets(%REF s : packed array [$u1..$u2:integer] of char); external;

var
     s : packed array [1..32] of char;

begin
     s := '                                ';
     gets(s);
     writeln(s);
end.
$ pas s2
$ link s2
$ run s2
1234567890
1234567890
$ run s2
12345678901234567890123456789012345678901234567890123456789012345678901234567890
12345678901234567890123456789012
%SYSTEM-F-ACCVIO, access violation, reason mask=00, virtual 
address=3039383736353430, PC=3039383736353430, PS=0000001B

   Improperly handled condition, image exit forced by last chance handler.
     Signal arguments:   Number = 0000000000000005
                         Name   = 000000000000000C
                                  0000000000000000
                                  3039383736353430
                                  3039383736353430
                                  000000000000001B

     Register dump:
     R0  = 0000000000000001  R1  = 000000000458D021  R2  = 3837363534333231
     R3  = 000000007AFC522A  R4  = 000000007FFCF814  R5  = 000000007FFCF934
     R6  = 000000007FFA0ED0  R7  = 000000007FFA0ED0  R8  = 000000007FF9CDE8
     R9  = 000000007FF9DDF0  R10 = 000000007FFA4F28  R11 = 000000007FFCDC18
     R12 = 000000007FFCDA98  R13 = FFFFFFFF81952110  R14 = 0000000000000000
     R15 = 000000007AF0C9E0  R16 = FFFFFFFFFFFEFFFF  R17 = 0000000000054070
     R18 = 0000000000000000  R19 = 000000007FFD0010  R20 = 00000000000187BC
     R21 = 0000000000000000  R22 = 0000000000000001  R23 = 0000000000010001
     R24 = 0000000000010001  R25 = 0000000000000001  R26 = 3039383736353433
     R27 = FFFFFFFF818011E0  R28 = FFFFFFFF802BD06C  R29 = 3635343332313039
     SP  = 000000007AE27AF0  PC  = 3039383736353430  PS  = 300000000000001B

Arne



More information about the Info-vax mailing list