Bug 2373

Summary: memory leak in sshd.c:2262
Product: Portable OpenSSH Reporter: Jakub Jelen <jjelen>
Component: sshdAssignee: Assigned to nobody <unassigned-bugs>
Status: CLOSED FIXED    
Severity: trivial CC: dtucker
Priority: P5    
Version: 6.7p1   
Hardware: Other   
OS: Linux   
Bug Depends on:    
Bug Blocks: 2360    
Attachments:
Description Flags
patch
none
revised patch none

Description Jakub Jelen 2015-03-28 02:20:20 AEDT
Created attachment 2577 [details]
patch

During some playing around with openss-6.8 I found one memory leak in server. This was introduced in
https://anongit.mindrot.org/openssh.git/commit/?id=5ecb41629860687b145be63b8877fabb6bae5eda

It happened that you are not freeing allocated string with local_ipaddr. This is nothing critical, but nice to have. Patch is quite simple (see attachment).
Comment 1 Darren Tucker 2015-04-15 15:36:23 AEST
Comment on attachment 2577 [details]
patch

>-	    get_local_ipaddr(sock_in), get_local_port());
>+	    (addr = get_local_ipaddr(sock_in)), get_local_port());

I think it'd be cleaner to do that assignment on a separate line rather than buried in the format string args.

>+	xfree(addr);

What version did you test this against?  xfree() is long gone.
Comment 2 Jakub Jelen 2015-04-15 17:23:49 AEST
Created attachment 2586 [details]
revised patch

Thanks for comments.

I was fixing this in recently released 6.8, but I don't know why I posted here xfree. Probably slow switching of context from fixing similar issue in older versions.

Adding revised patch with morning insight.
Comment 3 Darren Tucker 2015-04-16 09:24:29 AEST
I just committed a slightly modified version of this patch and it'll be in the 6.9 release.  Thanks.
Comment 4 Damien Miller 2015-08-11 23:02:21 AEST
Set all RESOLVED bugs to CLOSED with release of OpenSSH 7.1