开发者

segfaults when compiling on newer version of glibc ( 2.3 -> 2.10 )

开发者 https://www.devze.com 2023-01-24 15:31 出处:网络
I try to modify ssh session logging patch to sshd from kdvelectronics site. Code hasn\'t changed much from openssh 4.x to 5.x , but now sshd segfaults when script_open function calls ( as gdb says )

I try to modify ssh session logging patch to sshd from kdvelectronics site.

Code hasn't changed much from openssh 4.x to 5.x , but now sshd segfaults when script_open function calls ( as gdb says )

Core was generated by `sshd: root [priv]        '.
Program terminated with signal 11, Segmentation fault.
#0  0x00007f687910ae69 in vfprintf () from /lib/libc.so.6
(gdb) bt
#0  0x00007f687910ae69 in vfprintf () from /lib/libc.so.6
#1  0x00007f68791a98c2 in __fprintf_chk () from /lib/libc.so.6
#2  0x000000000044ed03 in script_open ()
#3  0x000000000040ad2c in main ()

The code that crashes is:

strftime(logname, sizeof(logname), "%F.%T", gmtime(&tvec));

or

snprintf(fname, sizeof(fname), "%s/openssh.%s.%08x.typescript", SCRIPTDIR, username, rnd);

Full script.c listing is here http://pastebin.com/48B39K8s , I've commented 开发者_StackOverflow社区line 50 and removed logname variable from line 53 .

I just wanna know, what changed in glibc since 2.3 that these functions cause segfault or where to read about it.


Ok, it turned out to be pretty simple. I've changed mentioned strings to

strftime(logname, FILENAME_MAX+1, "%F.%T", gmtime(&tvec));
snprintf(fname, FILENAME_MAX+1, "%s/openssh.%s.%08x.typescript", SCRIPTDIR, username, rnd);

Ofc it's dirty, but works.


I believe that the reason your code crashes is that (with line 50 commented out) you have left logname with undefined contents when you use it at line 60. You mentioned that you removed the logname reference from line 53 along with commenting out line 50 -- perhaps you just forgot to also remove it from line 60 in that case?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号