ChinaUnix.net
相关文章推荐:

stack预先设定一个初始化最大值每当存满的时候用realloc函数再次分配

简单的 stack trace 例程,C/C++ 两套接口 debug.h,前半是 C 接口,后半是 C++ 接口 [code]#ifndef DEBUG_H #define DEBUG_H #include #include #include #include #include #include #ifdef __cplusplus extern "C" { #endif // Will enable seperate output for each thread, set default level to EMERG int dbg_enable (); // Logging outp...

by wolf0403 - 程序开发 - 2006-09-19 04:37:43 阅读(572) 回复(0)

相关讨论

原文链接:http://insecure.org/stf/smashstack.html 不清楚是不是该发这里 还是内核源码版 考虑到这里人气要比那里旺 先发在这吧 问题是原文的最后例子 Small Buffer Overflows 我看的不是很懂 [code] exploit4.c ------------------------------------------------------------------------------ #include #define DEFAULT_OFFSET 0 #define DEFAULT_BUFFER_SIZE 512 #defi...

by duanius - C/C++ - 2009-05-30 22:40:56 阅读(1083) 回复(5)

简单的 stack trace 例程,C/C++ 两套接口 debug.h,前半是 C 接口,后半是 C++ 接口 [code]#ifndef DEBUG_H #define DEBUG_H #include #include #include #include #include #include #ifdef __cplusplus extern "C" { #endif // Will enable seperate output for each thread, set default level to EMERG int dbg_enable (); // Logging outp...

by wolf0403 - C/C++ - 2006-09-16 19:42:54 阅读(2450) 回复(1)

void fun1(int a, int b) { char buf_fun1[4]; ...... } void fun2(int a, int b , int c) { char buf_fun2[100]; ... } 在调fun1,fun2时它们的stack分布有些差异. fun1: stack(低地址) top of buf_fun1 fsp ret a b stack(高地址) .. fun2: stack(低地址...

by bmw1981bmw - Linux论坛 - 2004-09-25 09:07:36 阅读(313) 回复(0)

void fun1(int a, int b) { char buf_fun1[4]; ...... } void fun2(int a, int b , int c) { char buf_fun2[100]; ... } 在调fun1,fun2时它们的stack分布有些差异. fun1: stack(低地址) top of buf_fun1 fsp ret a b stack(高地址) .. fun2: stack(低地址...

by bmw1981bmw - C/C++ - 2004-09-30 17:45:33 阅读(2792) 回复(16)

函数原型:char* realloc(char *ptr, size_t new_size) ; ------------------------------ 问题1: realloc 之后,是不是把原来内的内容也拷贝进去? 问题2: realloc失败后,会返回NULL,如果这样的话: char *ptr = malloc(1024) ; ptr = realloc(ptr, 1024*100) ; // ptr = NULL ptr = NULL 了,那怎么free(ptr) 内泄漏?

by anank - C/C++ - 2008-09-02 07:56:45 阅读(1610) 回复(9)

需要将数据中的某些字节删除,相应地需要释放fg所占的内。比如将"asdfghjkl"中的"fg"删除,并返回"asdhjkl"。我下面的code来完成。 #include #include #include main() { char *p; p = malloc(10); strcpy (p, "asdfghjkl"); memmove(p+3, p+5, 5); p = realloc (p, 8); fprintf (stdout, "Str: %s\n", p); free(p); } 如何确定在调realloc之后,所分配的内大...

by yacare - C/C++ - 2006-10-31 14:32:38 阅读(1220) 回复(1)

分配malloc, realloc函数有两种工作方式:小块分配模式和大块模式 前者从低端开始忘高分,brk. 后者从高往低分,不brk. 在我的机器上128K是大模式,128K以下是小模式。大模式,brk不变,分配的内在brk数值上方。 brk在大模式下不变。处于非常小的原始数值。 编译该测试程序, ./a.out 127 ./a.out 130 分别看结果。 [CODE] #include #include #include #include

by 思一克 - C/C++ - 2007-05-28 15:43:27 阅读(1301) 回复(5)

pstack PID能打出java JVM的stack,但处不大。 谢谢

by brightcrest - Java - 2010-08-28 22:02:13 阅读(3639) 回复(3)
by 随风漂 - C/C++ - 2004-09-07 14:01:23 阅读(569) 回复(2)

[code]#include ; int main(int argc,char* argv[]) { int x; char buf[10]; x=8; buf[0]='a'; buf[1]='\0'; return; }[/code] 在gdb下看的汇编代码如下: [code]1: push %ebp 2: mov %esp %ebp 3: sub $0x28 %esp 4: and $0xfffffff0 %esp 5: mov $0x0 %eax 6: sub %eax %esp 7: mov %0x8 -12(%ebp) 8: mov %0x61 -40(%ebp) 9: mov %0x0 -39(%ebp) 10: leave 11: ...

by angelanpan - C/C++ - 2005-09-27 09:47:49 阅读(1334) 回复(15)