Bug 2373 - memory leak in sshd.c:2262
Summary: memory leak in sshd.c:2262
Status: CLOSED FIXED
Alias: None
Product: Portable OpenSSH
Classification: Unclassified
Component: sshd (show other bugs)
Version: 6.7p1
Hardware: Other Linux
: P5 trivial
Assignee: Assigned to nobody
URL:
Keywords:
Depends on:
Blocks: V_6_9
  Show dependency treegraph
 
Reported: 2015-03-28 02:20 AEDT by Jakub Jelen
Modified: 2015-08-11 23:02 AEST (History)
1 user (show)

See Also:


Attachments
patch (675 bytes, patch)
2015-03-28 02:20 AEDT, Jakub Jelen
no flags Details | Diff
revised patch (715 bytes, patch)
2015-04-15 17:23 AEST, Jakub Jelen
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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