summaryrefslogtreecommitdiff
path: root/ACE/apps/JAWS/clients/WebSTONE/src/cgi-send.c
blob: 5626836f6505ab82b607e07d02531b4075292d58 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/* $Id$ */
/*
 * Send 10K file; send random bits.
 *
 */

//FUZZ: disable check_for_improper_main_declaration

#include <stdio.h>
#include <stdlib.h>

#define FILE_SIZE       10240
#define MALLOC_FAILURE  "Out of memory"

int
main()
{
  int filesize;
  char *str_filesize;
  char *buffer;
  int index;

  printf("Content-type: text/plain\r\n\r\n");

  if ( !(str_filesize = getenv("QUERY_STRING")) )
    filesize = FILE_SIZE;
  else {
    if ( !strncmp(str_filesize, "size=", 5) )
      filesize = atoi(&(str_filesize[5]));
    else
      filesize = FILE_SIZE;
  }

  if ( !(buffer = (char *)malloc(filesize)) ) {
    fwrite(MALLOC_FAILURE, strlen(MALLOC_FAILURE), 1, stdout);
    return -1;
  }

  for (index=0; index< filesize; index++)
    /* generate random characters from A-Z */
    buffer[index] = rand() %26 + 63;

  fwrite(buffer, filesize, 1, stdout);

  free(buffer);

  return 0;
}