I get a segfault in my program and was trying to detect the source via gdb.
O/p of the gdb is as follows:
[Switching to Thread 0xb6dffb70 (LWP 6448)]
#0 0x00adc026 in __strlen_sse2_bsf () from /lib/libc.so/6
#1 0x08049e77 in sim_txn (fd=0x804c5c0) at rand_trace0.c:390
and at rand_trace0.c:390 I have the line
system_call_length = strlen("rename(")+strlen(filename1)+strlen(",")+strlen(filename)+strlen(")")+1;
Everything seems to be working before it.
I am at a loss.
Are
filename1andfilenameboth valid pointers to null-terminated strings? The most common reason you might get a segfault with that is if your pointer wasn’t properly initialized or if one of the strings isn’t null-terminated (possibly because of a buffer overflow) and thus is resulting instrlen()trying to read past the size of the allocated memory.