Finding the faults in a CGI POST handler

A student writes this CGI program to echo a POST request body back to the browser. The standard headers are included and the program compiles without warnings.


C
int main(void) {
    char buf[256];
    int n = atoi(getenv("CONTENT_LENGTH"));
    fread(buf, 1, n, stdin);
    printf("Got: %s\n", buf);
    return 0;
}


Which of the following statements about this program are true? Select all that apply.

Choose an answer

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

More CGI Programming Questions: