[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [open-cobol-list] CVS Update 20061015
From: |
Duilio Protti |
Subject: |
Re: [open-cobol-list] CVS Update 20061015 |
Date: |
Sun, 15 Oct 2006 20:50:37 -0300 (ART) |
User-agent: |
SquirrelMail/1.4.4 |
Hi,
The prerelease builds and run correctly here. However, in regard of bug
#1571083, I have found one more issue.
The bug is related to statements like PERFORM F WITH TEST BEFORE UNTIL P,
where, if P is true at the first time, F mustn't execute at all.
Currently, OpenCobol execute F once.
I.e. for the program:
IDENTIFICATION DIVISION.
PROGRAM-ID. WithTestBefore1.
PROCEDURE DIVISION.
MAIN.
PERFORM SAY-HELLO
WITH TEST BEFORE UNTIL 1 < 2.
SAY-HELLO.
DISPLAY 'Hello, world'.
"Hello, world" is displayed once.
The extra issue I have found, is that aside from the wrong control flow,
OpenCobol generate potentially dangerous code. For the previous program,
it generates (only relevant fragment showed):
{
while (1)
{
if ((cob_cmp_int (&c_9, 2) < 0))
break;
/* PERFORM SAY-HELLO THRU SAY-HELLO */
if (unlikely(++frame_index >= COB_STACK_SIZE))
cob_fatal_error (COB_FERROR_STACK);
frame_stack[frame_index].perform_through = 7;
frame_stack[frame_index].return_address = &&l_10;
goto l_7;
l_10:
frame_index--;
}
}
/* SAY-HELLO: */
l_7:;
/* withtestbefore1.cob:9: DISPLAY */
{
cob_new_display (0, 1, 1, &c_12);
}
if (frame_stack[frame_index].perform_through == 7)
goto *frame_stack[frame_index].return_address;
cob_current_module = cob_current_module->next;
return (*(int *) (b_2));
This is clearly dangerous: if test 'if ((cob_cmp_int (&c_9, 2) < 0))' is
true at the first iteration of the loop, control reach l_7: and then the
condition 'if (frame_stack[frame_index].perform_through == 7)' is
performed with 'perform_through' and 'return_address' fields
non-initialized.
If the garbage in 'perform_through' is by change equal to 7, then a goto
to (non-initialized) 'return_address' is performed, which in general will
result in a segfault (and the worst kind of bug, a random one).
Regards,
Duilio Protti.
> CVS updated.
> Tarball (AKA Prerelease) at :
> http://ww.sim-basis.de/open-cobol-0.33.tar.gz
>
> Too many things changed to list here.
> See the ChangeLog files in the top-level
> and sub-directories (cobc, libcob, config, bin, tests)
>
> Roger