Page MenuHomeFreeBSD

Fix a memory leak in telnetd
ClosedPublic

Authored by trix_juniper.net on Feb 20 2017, 3:55 PM.
Tags
None
Referenced Files
F114643574: D9689.diff
Mon, Apr 14, 7:43 PM
F114597525: D9689.diff
Mon, Apr 14, 7:04 AM
F114595090: D9689.id.diff
Mon, Apr 14, 6:38 AM
F114572829: D9689.id25424.diff
Mon, Apr 14, 2:12 AM
F114572757: D9689.id29114.diff
Mon, Apr 14, 2:11 AM
Unknown Object (File)
Tue, Apr 8, 10:39 PM
Unknown Object (File)
Sun, Mar 16, 9:50 PM
Unknown Object (File)
Mar 15 2025, 12:07 PM
Subscribers

Details

Summary

Fix memory leak in edithost

The problem is that when the parameter 'pat' is null, the function locally allocates a NULL string but never frees it.

Instead of tracking the local alloc, it is noted that the while(*pat) never enters when there is a local alloc.
So instead of doing the local alloc, check that 'pat' is null before the while(*pat) loop.

Test Plan

Run clang's static analyzer, scan-build, before to find the problem; run scan-build after to verify problem is resolved.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

trix_juniper.net retitled this revision from to Fix a memory leak in telnetd.
trix_juniper.net updated this object.
trix_juniper.net edited the test plan for this revision. (Show Details)
trix_juniper.net added reviewers: stevek, markm.
trix_juniper.net set the repository for this revision to rS FreeBSD src repository - subversion.
markm edited edge metadata.

Looks good to me.

contrib/telnet/telnetd/utility.c
364 ↗(On Diff #25424)

Oooh, yuk. Well spotted.

This revision is now accepted and ready to land.Feb 24 2017, 6:34 PM

Credit goes to clang¹s static analyzer scan-build.
I only read the reports it generated.
Tom

This revision was automatically updated to reflect the committed changes.