Vsprintf与Vsnprintf造成的栈越界
Foreword 一个陈年老问题,总算找到根源,由此也发现了很多之前不曾注意的一些细节,这些地方都有可能造成栈越界 之前有发现栈越界,但是实际追查起来还是比较困难的,特别是想知道从哪一刻哪个位置开始栈越界,就更难查了 https://elmagnifico.tech/2025/04/10/StackOverflow/ vsprintf vsprintf vsprintf就是一个根据列表参数进行格式化的函数,转成我们熟悉的printf里输出的内容 int vsprintf(char *str, const char *format, va_list arg) 一般都是这样组合在一起 va_list ap; va_start(ap, fmt); vsprintf(..
read_more再一次理解 C++ 中的 extern "C
本文是“攻玉计划”的一部分,翻译自 https://stackoverflow.com/questions/1041866/what-is-the-effect-of-extern-c-in-c 中 Ciro Santilli 的回答通过反汇编了解 extern “C” 的作用main.cpp12345678910void f() {}void g();extern "C" { void ef() {} void eg();}/* Prevent g and eg from being optimized away. */void h() { g(); eg(); }将上述代码编译为 ELF 格式的二进制,然后反汇编:12g++ -c -std=c++11 -Wall -Wextra -pedant..
read_more