com php-src: avoid repeated strlen usage, remove unused vars: TSRM/tsrm_win32.c
| From: | Anatol Belski | Date: | Thu, 13 Nov 2014 18:57:34 +0000 |
| Subject: | com php-src: avoid repeated strlen usage, remove unused vars: TSRM/tsrm_win32.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-83081@lists.php.net to get a copy of this message | ||
Commit: e6ea376a91514c59d21f4b53ccbb8c06fa42447b
Author: Anatol Belski <ab@php.net> Thu, 13 Nov 2014 16:00:00 +0100
Parents: 14ccac0237853f05beb72f3b05156d0765210bfb
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=e6ea376a91514c59d21f4b53ccbb8c06fa42447b
Log:
avoid repeated strlen usage, remove unused vars
Changed paths:
M TSRM/tsrm_win32.c
Diff:
diff --git a/TSRM/tsrm_win32.c b/TSRM/tsrm_win32.c
index 7194dff..9765874 100644
--- a/TSRM/tsrm_win32.c
+++ b/TSRM/tsrm_win32.c
@@ -106,16 +106,18 @@ TSRM_API void tsrm_win32_shutdown(void)
char * tsrm_win32_get_path_sid_key(const char *pathname TSRMLS_DC)
{
PSID pSid = TWG(impersonation_token_sid);
- DWORD sid_len = pSid ? GetLengthSid(pSid) : 0;
TCHAR *ptcSid = NULL;
char *bucket_key = NULL;
+ size_t ptc_sid_len, pathname_len;
+
+ pathname_len = strlen(pathname);
if (!pSid) {
- bucket_key = (char *)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, strlen(pathname) + 1);
+ bucket_key = (char *)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, pathname_len + 1);
if (!bucket_key) {
return NULL;
}
- memcpy(bucket_key, pathname, strlen(pathname));
+ memcpy(bucket_key, pathname, pathname_len);
return bucket_key;
}
@@ -123,14 +125,16 @@ char * tsrm_win32_get_path_sid_key(const char *pathname TSRMLS_DC)
return NULL;
}
- bucket_key = (char *)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, strlen(pathname) +
strlen(ptcSid) + 1);
+
+ ptc_sid_len = strlen(ptcSid);
+ bucket_key = (char *)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, pathname_len + ptc_sid_len +
1);
if (!bucket_key) {
LocalFree(ptcSid);
return NULL;
}
- memcpy(bucket_key, ptcSid, strlen(ptcSid));
- memcpy(bucket_key + strlen(ptcSid), pathname, strlen(pathname) + 1);
+ memcpy(bucket_key, ptcSid, ptc_sid_len);
+ memcpy(bucket_key + ptc_sid_len, pathname, pathname_len + 1);
LocalFree(ptcSid);
return bucket_key;
@@ -139,11 +143,8 @@ char * tsrm_win32_get_path_sid_key(const char *pathname TSRMLS_DC)
PSID tsrm_win32_get_token_sid(HANDLE hToken)
{
- BOOL bSuccess = FALSE;
DWORD dwLength = 0;
PTOKEN_USER pTokenUser = NULL;
- PSID sid;
- PSID *ppsid = &sid;
DWORD sid_len;
PSID pResultSid = NULL;
@@ -204,7 +205,6 @@ TSRM_API int tsrm_win32_access(const char *pathname, int mode TSRMLS_DC)
BYTE * psec_desc = NULL;
BOOL fAccess = FALSE;
- BOOL bucket_key_alloc = FALSE;
realpath_cache_bucket * bucket = NULL;
char * real_path = NULL;
@@ -242,7 +242,6 @@ TSRM_API int tsrm_win32_access(const char *pathname, int mode TSRMLS_DC)
was impersonating already, this function uses that impersonation context.
*/
if(!OpenThreadToken(GetCurrentThread(), TOKEN_ALL_ACCESS, TRUE, &thread_token)) {
- DWORD err = GetLastError();
if (GetLastError() == ERROR_NO_TOKEN) {
if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ALL_ACCESS, &thread_token)) {
TWG(impersonation_token) = NULL;