Bug 1496

Summary: ssh fails with xmalloc: zero size
Product: Portable OpenSSH Reporter: Tomas Mraz <t8m>
Component: sshAssignee: Assigned to nobody <unassigned-bugs>
Status: CLOSED FIXED    
Severity: normal CC: cjwatson, djm, josh, vapier
Priority: P2 Keywords: patch
Version: 5.1p1   
Hardware: Other   
OS: Linux   
Bug Depends on:    
Bug Blocks: 1481    
Attachments:
Description Flags
Patch which fixes the zero length banner problem.
none
Correct patch none

Description Tomas Mraz 2008-07-31 19:08:50 AEST
Created attachment 1553 [details]
Patch which fixes the zero length banner problem.

ssh fails with xmalloc: zero size when connecting to a server with present but empty banner.

Also the processing of the received banner through strnvis() is unfortunate in the regard that it mangles banners with international characters. The processing should be done according to the current locale and allow the international characters to be printed unmangled.
Comment 1 Tomas Mraz 2008-07-31 19:21:05 AEST
Created attachment 1554 [details]
Correct patch

Actually according to the strnvis man page the dest must be null terminated in case the len is 0 or all the characters are expanded to 4 times length.
Comment 2 Josh Triplett 2008-08-07 05:56:25 AEST
I can confirm this problem.  I observed it when attempting to connect to the management module of an IBM BladeCenter via SSH.  It did not occur with previous versions of SSH.
Comment 3 Colin Watson 2008-08-29 23:50:26 AEST
Shouldn't you pass len * 4 + 1 as the third argument to strnvis too? openbsd-compat/vis.c says:

 *      Strnvis will write no more than siz-1 bytes (and will NULL terminate).
Comment 4 Tomas Mraz 2008-08-30 20:25:31 AEST
Hmm, yes. The current patch means that in case that all characters are expanded, the last character of the expanded string will be truncated.
Comment 5 Mike Frysinger 2008-11-03 19:41:10 AEDT
this has been fixed in openbsd now:
http://www.openbsd.org/cgi-bin/cvsweb/src/usr.bin/ssh/sshconnect2.c.diff?r1=1.166;r2=1.168
Comment 6 Damien Miller 2009-01-21 20:12:50 AEDT
Yes, this will be in openssh-5.2
Comment 7 Damien Miller 2009-02-23 13:35:57 AEDT
Close bugs fixed/reviewed for openssh-5.2 release