sahlberg / libsmb2

SMB2/3 userspace client
Other
310 stars 126 forks source link

smb2_opendir memory leak #324

Open memecode opened 3 months ago

memecode commented 3 months ago

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.

Wolf3s commented 3 months ago

Did you tried to create a pull request here?

memecode commented 3 months ago

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.

Wolf3s commented 3 months ago

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.