PSID Leakage Problem , please check the code
-
I am doing everything for allocating and freeing sid structure but it always gives leakages please check the code : BOOL GetAll (char* sFileOrFolderName ) { DWORD dwRtnCode = 0; PSID ownerSid = NULL; HANDLE hFile; hFile = CreateFile( sFileOrFolderName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if (hFile == INVALID_HANDLE_VALUE) { return FALSE; } dwRtnCode = GetSecurityInfo( hFile, SE_FILE_OBJECT, OWNER_SECURITY_INFORMATION, (&ownerSid), NULL, NULL, NULL, NULL); if( !ownerSid ) { CloseHandle(hFile); return FALSE; } LocalFree((HLOCAL)ownerSid); CloseHandle(hFile); return TRUE ; } int _tmain(int argc, _TCHAR* argv[]) { while(1) { if(!GetAll("d:\\aa.txt")) { printf("\nFailed"); } Sleep(1000); } return 0; }
-
I am doing everything for allocating and freeing sid structure but it always gives leakages please check the code : BOOL GetAll (char* sFileOrFolderName ) { DWORD dwRtnCode = 0; PSID ownerSid = NULL; HANDLE hFile; hFile = CreateFile( sFileOrFolderName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if (hFile == INVALID_HANDLE_VALUE) { return FALSE; } dwRtnCode = GetSecurityInfo( hFile, SE_FILE_OBJECT, OWNER_SECURITY_INFORMATION, (&ownerSid), NULL, NULL, NULL, NULL); if( !ownerSid ) { CloseHandle(hFile); return FALSE; } LocalFree((HLOCAL)ownerSid); CloseHandle(hFile); return TRUE ; } int _tmain(int argc, _TCHAR* argv[]) { while(1) { if(!GetAll("d:\\aa.txt")) { printf("\nFailed"); } Sleep(1000); } return 0; }
Akin Ocal wrote:
...but it always gives leakages...
How are you verifying these "leakages?"
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne