Saturday, February 12, 2011

unzip tarball files:

usually to unzip a *.tar.gz file i used 'tar' command. The syntax of the tar command is:

Syntax:
tar -option file_name.tar.gz

tar -xzfvp file_name.tar.gz
the above command will unzip a tarball file.

but when i tries to unzip it says error 'vp can not open file', so am unable to unzip a file. Then i found a alternative command to unzip a tar.gz files. Its gzip command i command i used to unzip my tarball. The command i used is as follows:

gzip -dc file_name.tar.gz | tar xf -

Sunday, February 6, 2011

stack smashing detected

'stack smash'-"buffer overflow...." when i tried to run a array sort program the following error shows.


*** stack smashing detected ***: ./a.out terminated
======= Backtrace: =========
/lib/libc.so.6(__fortify_fail+0x50)[0x215970]
/lib/libc.so.6(+0xe591a)[0x21591a]
./a.out[0x8048520]
/lib/libc.so.6(__libc_start_main+0xe7)[0x146ce7]
./a.out[0x8048381]
======= Memory map: ========
00130000-00287000 r-xp 00000000 08:09 1574075    /lib/libc-2.12.1.so
00287000-00289000 r--p 00157000 08:09 1574075    /lib/libc-2.12.1.so
00289000-0028a000 rw-p 00159000 08:09 1574075    /lib/libc-2.12.1.so
0028a000-0028d000 rw-p 00000000 00:00 0
00828000-00829000 r-xp 00000000 00:00 0          [vdso]
0085f000-0087b000 r-xp 00000000 08:09 1574071    /lib/ld-2.12.1.so
0087b000-0087c000 r--p 0001b000 08:09 1574071    /lib/ld-2.12.1.so
0087c000-0087d000 rw-p 0001c000 08:09 1574071    /lib/ld-2.12.1.so
0089a000-008b4000 r-xp 00000000 08:09 1572944    /lib/libgcc_s.so.1
008b4000-008b5000 r--p 00019000 08:09 1572944    /lib/libgcc_s.so.1
008b5000-008b6000 rw-p 0001a000 08:09 1572944    /lib/libgcc_s.so.1
08048000-08049000 r-xp 00000000 08:09 655695     /root/a.out
08049000-0804a000 r--p 00000000 08:09 655695     /root/a.out
0804a000-0804b000 rw-p 00001000 08:09 655695     /root/a.out
0962d000-0964e000 rw-p 00000000 00:00 0          [heap]
b781e000-b781f000 rw-p 00000000 00:00 0
b7832000-b7835000 rw-p 00000000 00:00 0
bfbbd000-bfbde000 rw-p 00000000 00:00 0          [stack]
Aborted

when i tries to found why this error happens, then i found i tried to access the array bound limit in my program. when i surf, i found a gcc command, for stack protection,

gcc -fno-stack-protector file_name.c

this command protects the stack overflow...and produces the result when you runs the program,if the error still precedes your program tries to access illegal memory location...