Fix resource leaks in msc_status_engine_mac_address#3391
Fix resource leaks in msc_status_engine_mac_address#3391airween merged 1 commit intoowasp-modsecurity:v2/masterfrom
msc_status_engine_mac_address#3391Conversation
|
Hm... After looking a bit more, there seems to be a leak on all platforms. But on Windows and Mac, it's just a memory leak. Maybe |
`goto end` jumped over freeing/releasing resources for all platforms. For Linux, this caused a leak of open socket. For other platforms, it's just a memory leak.
msc_status_engine_mac_addressmsc_status_engine_mac_address
|
|
Hi @amezin,
I can check this next weekend. I'll try to add some test to check this PR (or feel free to add some - see |
|
BTW v3 also has the same issue - #3392 - because the code (for mac address retrieval) is mostly the same As far as I understand, there are windows/mac tests on v3 |
Thanks again,
Yes, v3 has an excellent test framework (but that's a library). And these tests can be run on any platform where the library can be built. In GH workflow, we run the tests on Linux (32 and 64 bit), Mac OSX and Windows. I'm going to merge this PR - thanks again! |



what
Close the socket created and free the memory allocated in
msc_status_engine_mac_address()in all code paths.why
Linux:
The socket is used only temporarily. Current implementation leaks the socket. For example, if
SecRemoteRulesis used anywhere in the config,systemctl reload httpd/systemctl reload apache2increases the count of open sockets in all Apache processes (well, it happens in the main process, and forked ones just inherit the problem).Other platforms:
goto endjust jumped over the calls freeing the memory.references