Log in

View Full Version : # 3 lines C-prog hurts MS VC


nezumi-lab
January 13th, 2009, 03:21
do you trust your compiler? do you complete “secondhand” sources? yeah, we all do that. but do you know that evil sources might hurt your compiler and sometimes even abuse your host OS (if compiler works inside guest VM Ware/Virtual PC environment). no MS specific extension! just pure ANSI C!

well, try this…

#include “stdio.h”
#include “limits.h”
int hack[INT_MAX] = {1,2,3};
main(){
printf(”hello world!\n”; return hack[INT_MAX-1];
}

what happened? oh… trying to create a very big array (2Gb!) complier fed up all memory and end up with error. if you don’t have enough physical memory and page file is not disabled - OS is hunting hdd for a long time, slowing down the whole system.

the same trick works with some assemblers - just define a huge array (TASM and MASM are affected).

I wonder: how many translators have this bug? please, download ("http://nezumi-lab.org/ffh/c-DoS.zip")the source code, try to compile it and mail result to info#re-lab.org or leave your comment here. please, test every translator you have under your hands. not only C/C++ but DELPHI/Pascal/ASM as well. thanks!



http://nezumi-lab.org/blog/?p=61

floop.org
January 13th, 2009, 14:21
$ gcc -o test c-DoS.c
c-DoS.c:32: error: size of array ‘hack’ is too large