mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-07-14 17:47:33 -05:00
Make get_user_sid() return the cached copy if one already exists.
A user reported in January that locking down our process ACL causes get_user_sid's call to OpenProcessToken to fail with a permissions error. This _shouldn't_ be important, because we'll already have found and cached the user SID before getting that far - but unfortunately the call to get_user_sid in winnpc.c was bypassing the cache and trying the whole process again. This fix changes the memory ownership semantics of get_user_sid(): it's now an error to free the value it gives you, or else the *next* call to get_user_sid() will return a stale pointer. Hence, also removed those frees everywhere they appear.
This commit is contained in:
@ -1934,7 +1934,6 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
|
||||
debug(("couldn't get default SID\n"));
|
||||
#endif
|
||||
CloseHandle(filemap);
|
||||
sfree(ourself);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1947,7 +1946,6 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
|
||||
rc));
|
||||
#endif
|
||||
CloseHandle(filemap);
|
||||
sfree(ourself);
|
||||
sfree(ourself2);
|
||||
return 0;
|
||||
}
|
||||
@ -1968,7 +1966,6 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
|
||||
!EqualSid(mapowner, ourself2)) {
|
||||
CloseHandle(filemap);
|
||||
LocalFree(psd);
|
||||
sfree(ourself);
|
||||
sfree(ourself2);
|
||||
return 0; /* security ID mismatch! */
|
||||
}
|
||||
@ -1976,7 +1973,6 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
|
||||
debug(("security stuff matched\n"));
|
||||
#endif
|
||||
LocalFree(psd);
|
||||
sfree(ourself);
|
||||
sfree(ourself2);
|
||||
} else {
|
||||
#ifdef DEBUG_IPC
|
||||
|
Reference in New Issue
Block a user