Closed Bug 1471943 Opened 3 years ago Closed 3 years ago

NetworkInfoServiceLinux.cpp: Possible socket resource leak

Categories

(Core :: Networking: WebSockets, defect, P3)

defect

Tracking

()

RESOLVED FIXED
mozilla63
Tracking Status
firefox63 --- fixed

People

(Reporter: rbartlensky, Assigned: rbartlensky)

References

Details

(Whiteboard: [necko-triaged])

Attachments

(1 file)

The infer static analyzer reported a resource leak here: https://searchfox.org/mozilla-central/source/netwerk/base/NetworkInfoServiceLinux.cpp#64 and I think it might be right.

The autoCloseSocket is defined at https://searchfox.org/mozilla-central/source/netwerk/base/NetworkInfoServiceLinux.cpp#34-36 and it is a ScopeExit object. In this case it holds a file descriptor, and when it goes out of scope runs the system call close.

If the execution manages to reach https://searchfox.org/mozilla-central/source/netwerk/base/NetworkInfoServiceLinux.cpp#64 the ScopeExit object will no longer free the resource (because the release method sets a variable which makes the destructor skip the freeing of the resource), thus causing a resource leak.

It can be seen here: https://searchfox.org/mozilla-central/source/netwerk/base/NetworkInfoServiceLinux.cpp#57,69 that the file descriptor is passed to another function before executing the line in question, but the file descriptor is not closed anywhere.
Summary: Possible socket resource leak → NetworkInfoServiceLinux.cpp: Possible socket resource leak
Priority: -- → P3
Whiteboard: [necko-triaged]
Attachment #8989198 - Flags: review?(bpostelnicu)
Attachment #8989198 - Flags: review?(bpostelnicu) → review?(valentin.gosu)
I think valentin should take care of this review, since he's the reviewer for this component.
Comment on attachment 8989198 [details]
Bug 1471943: Remove release call to ensure socket is closed.

https://reviewboard.mozilla.org/r/254250/#review261584

That's a good catch.
Attachment #8989198 - Flags: review?(valentin.gosu) → review+
Pushed by bpostelnicu@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/d53abfceeac2
Remove release call to ensure socket is closed. r=valentin
https://hg.mozilla.org/mozilla-central/rev/d53abfceeac2
Status: NEW → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla63
You need to log in before you can comment on or make changes to this bug.