Overflow over scanf(“%8s”, string)?

前端 未结 4 1650
清酒与你
清酒与你 2020-12-06 14:46

I know it\'s possible to overflow ordinary code:

char string[9];

scanf(\"%s\", string).

But is it possible to overflow scanf(\"%8s\

4条回答
  •  孤城傲影
    2020-12-06 15:13

    As ysth pointed out, the array should be able to contain the string and the terminating null-character, so using an 8-byte array (especially if it's allocated on the stack, as it is in your code) is very likely to mess it up.

提交回复
热议问题