What is the meaning of `printf(“%p”)` without arguments

后端 未结 4 726
半阙折子戏
半阙折子戏 2021-01-13 05:16

I of course know it used to output pointer with arguments.

I read book Writing Secure Code by Michael Howard and David LeBlanc.

One program in book

4条回答
  •  醉话见心
    2021-01-13 05:59

    The behaviour of printf("Now the stack looks like:\n%p\n%p\n%p\n%p\n%p\n%p\n\n"); is undefined since your argument list does not match the input string.

    The authors are conjecting that this particular misuse of printf will inject variables from the current stack, and output their addresses. Sometimes they might be correct. Other times the compiler might eat your cat.

提交回复
热议问题