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
Unknown Object (File)
Sat, Jan 18, 4:31 PM
Unknown Object (File)
Thu, Jan 16, 2:34 AM
Unknown Object (File)
Fri, Jan 3, 4:51 PM
Unknown Object (File)
Dec 5 2024, 6:58 PM
Unknown Object (File)
Dec 4 2024, 7:36 PM
Unknown Object (File)
Dec 4 2024, 7:36 PM
Unknown Object (File)
Dec 4 2024, 7:36 PM
Unknown Object (File)
Dec 4 2024, 5:50 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.