Revert "Use a variable on the stack to not have a temporary in the call"
[ACE_TAO.git] / ACE / apps / JAWS / clients / WebSTONE / src / cgi-send.c
blobb793e248433f7fdbf8fe725d87cdb6ea9c0ea8f2
1 /*
2 * Send 10K file; send random bits.
3 */
5 //FUZZ: disable check_for_improper_main_declaration
7 #include <stdio.h>
8 #include <stdlib.h>
10 #define FILE_SIZE 10240
11 #define MALLOC_FAILURE "Out of memory"
13 int
14 main()
16 int filesize;
17 char *str_filesize;
18 char *buffer;
19 int index;
21 printf("Content-type: text/plain\r\n\r\n");
23 if ( !(str_filesize = getenv("QUERY_STRING")) )
24 filesize = FILE_SIZE;
25 else {
26 if ( !strncmp(str_filesize, "size=", 5) )
27 filesize = atoi(&(str_filesize[5]));
28 else
29 filesize = FILE_SIZE;
32 if ( !(buffer = (char *)malloc(filesize)) ) {
33 fwrite(MALLOC_FAILURE, strlen(MALLOC_FAILURE), 1, stdout);
34 return -1;
37 for (index=0; index< filesize; index++)
38 /* generate random characters from A-Z */
39 buffer[index] = rand() %26 + 63;
41 fwrite(buffer, filesize, 1, stdout);
43 free(buffer);
45 return 0;