nerdexam
EC-Council

312-92 · Question #55

What would be the result of the following code? #include <stdio.h> #include <stdlib.h> int main(int argc, char argv[]) { char input=malloc(20); char *output=malloc(20); strcpy(output, "normal…

The correct answer is B. Heap overflow. See the full explanation below for the reasoning.

Question

What would be the result of the following code? #include <stdio.h> #include <stdlib.h> int main(int argc, char *argv[]) { char *input=malloc(20); char *output=malloc(20); strcpy(output, "normal output"); strcpy(input, argv[1]); printf("input at %p: %s\n", input, input); printf("output at %p: %s\n", output, output); printf("\n\n%s\n", output); }

Options

  • AStack buffer overflow
  • BHeap overflow
  • CQuery string manipulation
  • DPointer Subterfuge

How the community answered

(54 responses)
  • A
    2% (1)
  • B
    76% (41)
  • C
    15% (8)
  • D
    7% (4)

Community Discussion

No community discussion yet for this question.

Full 312-92 Practice