strncpy发生stack corruption detected(-fstack-protector)栈溢出

代码:

char line[MAX] = {0};

strncpy(line,pBeginObj,(ptemp - pBeginObj + 1));

log如下:

解释:

char *strncpy(char *dest, const char *src, int n)

把src所指向的字符串中以src地址开始的前n个字节复制到dest所指的数组中

0x746d498e86 - 0x756d498cda = 1ac = 428

MAX = 256;

429>256,strncpy内存拷贝越界,导致栈溢出!!!

猜你喜欢

转载自blog.csdn.net/u012906122/article/details/103639970
今日推荐