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)
Thu, Mar 7, 6:42 PM
Unknown Object (File)
Thu, Mar 7, 6:42 PM
Unknown Object (File)
Thu, Mar 7, 6:42 PM
Unknown Object (File)
Thu, Mar 7, 6:36 PM
Unknown Object (File)
Feb 5 2024, 11:16 PM
Unknown Object (File)
Jan 26 2024, 6:49 AM
Unknown Object (File)
Dec 20 2023, 12:59 AM
Unknown Object (File)
Dec 15 2023, 9:30 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 Skipped
Unit
Tests Skipped

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

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.