Memory leak in cli_query_secdesc api

Brett A. Funderburg brettf at deepfile.com
Tue Jul 22 20:24:47 GMT 2003


Poor formatting munged the script the first time...Corrected version
below.

Regards,

brett
-----

import string
from samba import smb

GENERIC_READ = 0x80000000
credentials = {'domain': 'DOM-TEST',
                'username': 'Administrator',
                'password': 'admin'}
server = 'smb-test.deepfile.com'
volume = 'E$'

def leak():

    list_of_filepaths = file('/deepfs/tmp/filepaths.txt', 'r')

    # pass exceptions to user
    cnn = smb.connect(server)
    cnn.session_request(server)
    cnn.negprot()
    cnn.session_setup(credentials)
    cnn.tconx(volume)

    for path in list_of_filepaths:
        path = path.rstrip()
        fid = None
        try:
           # raises RuntimeError
           fid = cnn.nt_create_andx(path, GENERIC_READ)
        except:
            pass
        else:
# Uncomment here to see leak
#           sec_desc = None
#            try:
#                sec_desc = cnn.query_secdesc(fid)
#            except:
#                pass    # skip and move on
#
#            del sec_desc # be explicit; don't rely on GC
            cnn.close(fid)

        del fid # be explicit; don't rely on GC

if __name__ == "__main__":
    leak()





More information about the samba-technical mailing list