Frank Heckenbach wrote:
Adriaan van Os wrote:
Mirsad Todorovac wrote:
I have recently studied several forms of viruses and security holes in software. Many if not 90% of recent exploits depend on holes introduced through buffer overruns, such as this C example:
printbuffer() { char buffer[100];
gets (buffer); /* oops!*/ fp = fopen("LPT1:", "w"); fputs (buffer, fp);
}
Is Pascal and namely GNU Pascal safer re: buffer overruns? How much does runtime range checking help
Yes. In particular, some holes are intentional, either for compatibility with other dialects (pointer-arithmetic etc.), or for performance reasons (possibility to turn off checks).
There are other holes, such as dangling pointers and using unintialized variables, which GPC cannot detect at all yet. It might do in the future, but implementing them will be very hard, so don't hold your breath.
I have always presumed that -Wuninitialized (combined with -On, where n
=1) does warn about uninitialized variables. The following simple test
seems to confirm that, but only for local variables, not for global variables (which maybe are automatically initialized to 0 ?? (a dangerous presumption by the way)).
program uninitialized;
var j: integer;
procedure P; var i: integer; begin i:= i + 1; writeln( 'i =', i) end;
begin P; writeln( 'j = ', j); end.
Regards,
Adriaan van Os