libsmb2 icon indicating copy to clipboard operation
libsmb2 copied to clipboard

smb2_opendir memory leak

Open memecode opened this issue 1 year ago • 3 comments

So far as I can see... in the implementation of smb2_opendir, if wait_for_reply fails and it falls into the SMB2_STATUS_CANCELLED handler the cb_data memory leaks. It returned NULL instead of free'ing the memory.

In fact the whole 'cb_data->status = SMB2_STATUS_CANCELLED' seems kinda pointless if no one else has that pointer right?

The wait should probably be:

	if (wait_for_reply(smb2, cb_data) < 0) {
                free(cb_data);
                return NULL;
        }

Seems to also be the case for the other sync functions; smb2_stat, smb2_rename etc.

memecode avatar Mar 21 '24 00:03 memecode

Did you tried to create a pull request here?

Wolf3s avatar Mar 28 '24 10:03 Wolf3s

Did you tried to create a pull request here?

No I've been busy with other things and haven't actually fixed it myself. My focus was on getting a fuse wrapper working with it. Which seems to be fairly successful. Not withstanding some threading issue speed bumps.

memecode avatar Mar 28 '24 11:03 memecode

Did you tried to create a pull request here?

No I've been busy with other things and haven't actually fixed it myself. My focus was on getting a fuse wrapper working with it. Which seems to be fairly successful. Not withstanding some threading issue speed bumps.

This issue is more related to t_socket integers than something else but your approach seems pretty intersting.

Wolf3s avatar Mar 28 '24 11:03 Wolf3s

Fixed in current master. Tests have been added to the testsuite for this as well.

sahlberg avatar Dec 18 '24 20:12 sahlberg