hash_table *hid;
LOCAL_ARRAY(char, buf, BUFSIZ);
LOCAL_ARRAY(char, todelete, BUFSIZ);
- hash_link *walker = NULL;
+ hash_link *walker = nullptr;
todelete[0] = '\0';
printf("init\n");
SECURITY_STATUS SecurityStatus = SEC_E_OK;
static DWORD cbMaxToken = 0;
-static uint8_t * pClientBuf = NULL;
-static uint8_t * pServerBuf = NULL;
+static uint8_t * pClientBuf = nullptr;
+static uint8_t * pServerBuf = nullptr;
static AUTH_SEQ NTLM_asServer = {};
#endif
/* Function pointers */
-ACCEPT_SECURITY_CONTEXT_FN _AcceptSecurityContext = NULL;
-ACQUIRE_CREDENTIALS_HANDLE_FN _AcquireCredentialsHandle = NULL;
-COMPLETE_AUTH_TOKEN_FN _CompleteAuthToken = NULL;
-DELETE_SECURITY_CONTEXT_FN _DeleteSecurityContext = NULL;
-FREE_CONTEXT_BUFFER_FN _FreeContextBuffer = NULL;
-FREE_CREDENTIALS_HANDLE_FN _FreeCredentialsHandle = NULL;
-INITIALIZE_SECURITY_CONTEXT_FN _InitializeSecurityContext = NULL;
-QUERY_SECURITY_PACKAGE_INFO_FN _QuerySecurityPackageInfo = NULL;
+ACCEPT_SECURITY_CONTEXT_FN _AcceptSecurityContext = nullptr;
+ACQUIRE_CREDENTIALS_HANDLE_FN _AcquireCredentialsHandle = nullptr;
+COMPLETE_AUTH_TOKEN_FN _CompleteAuthToken = nullptr;
+DELETE_SECURITY_CONTEXT_FN _DeleteSecurityContext = nullptr;
+FREE_CONTEXT_BUFFER_FN _FreeContextBuffer = nullptr;
+FREE_CREDENTIALS_HANDLE_FN _FreeCredentialsHandle = nullptr;
+INITIALIZE_SECURITY_CONTEXT_FN _InitializeSecurityContext = nullptr;
+QUERY_SECURITY_PACKAGE_INFO_FN _QuerySecurityPackageInfo = nullptr;
#ifdef UNICODE
-QUERY_CONTEXT_ATTRIBUTES_FN_W _QueryContextAttributes = NULL;
+QUERY_CONTEXT_ATTRIBUTES_FN_W _QueryContextAttributes = nullptr;
#else
-QUERY_CONTEXT_ATTRIBUTES_FN_A _QueryContextAttributes = NULL;
+QUERY_CONTEXT_ATTRIBUTES_FN_A _QueryContextAttributes = nullptr;
#endif
void UnloadSecurityDll(void)
xfree(pClientBuf);
xfree(pServerBuf);
- _AcceptSecurityContext = NULL;
- _AcquireCredentialsHandle = NULL;
- _CompleteAuthToken = NULL;
- _DeleteSecurityContext = NULL;
- _FreeContextBuffer = NULL;
- _FreeCredentialsHandle = NULL;
- _InitializeSecurityContext = NULL;
- _QuerySecurityPackageInfo = NULL;
- _QueryContextAttributes = NULL;
-
- hModule = NULL;
+ _AcceptSecurityContext = nullptr;
+ _AcquireCredentialsHandle = nullptr;
+ _CompleteAuthToken = nullptr;
+ _DeleteSecurityContext = nullptr;
+ _FreeContextBuffer = nullptr;
+ _FreeCredentialsHandle = nullptr;
+ _InitializeSecurityContext = nullptr;
+ _QuerySecurityPackageInfo = nullptr;
+ _QueryContextAttributes = nullptr;
+
+ hModule = nullptr;
}
HMODULE LoadSecurityDll(int mode, const char * SSP_Package)
{
TCHAR lpszDLL[MAX_PATH];
OSVERSIONINFO VerInfo;
- PSecPkgInfo pSPI = NULL;
+ PSecPkgInfo pSPI = nullptr;
/*
* Find out which security DLL to use, depending on
* We have to use security.dll on Windows NT 4.0.
* All other operating systems, we have to use Secur32.dll
*/
- hModule = NULL;
+ hModule = nullptr;
if ((mode != SSP_BASIC) && (mode != SSP_NTLM))
return hModule;
NTLM_mode = mode;
_AcceptSecurityContext = farproc_cast<ACCEPT_SECURITY_CONTEXT_FN>(GetProcAddress(hModule, "AcceptSecurityContext"));
if (!_AcceptSecurityContext) {
UnloadSecurityDll();
- hModule = NULL;
+ hModule = nullptr;
return hModule;
}
#ifdef UNICODE
#endif
if (!_AcquireCredentialsHandle) {
UnloadSecurityDll();
- hModule = NULL;
+ hModule = nullptr;
return hModule;
}
_CompleteAuthToken = farproc_cast<COMPLETE_AUTH_TOKEN_FN>(GetProcAddress(hModule, "CompleteAuthToken"));
if (!_CompleteAuthToken) {
UnloadSecurityDll();
- hModule = NULL;
+ hModule = nullptr;
return hModule;
}
_DeleteSecurityContext = farproc_cast<DELETE_SECURITY_CONTEXT_FN>(GetProcAddress(hModule, "DeleteSecurityContext"));
if (!_DeleteSecurityContext) {
UnloadSecurityDll();
- hModule = NULL;
+ hModule = nullptr;
return hModule;
}
_FreeContextBuffer = farproc_cast<FREE_CONTEXT_BUFFER_FN>(GetProcAddress(hModule, "FreeContextBuffer"));
if (!_FreeContextBuffer) {
UnloadSecurityDll();
- hModule = NULL;
+ hModule = nullptr;
return hModule;
}
_FreeCredentialsHandle = farproc_cast<FREE_CREDENTIALS_HANDLE_FN>(GetProcAddress(hModule, "FreeCredentialsHandle"));
if (!_FreeCredentialsHandle) {
UnloadSecurityDll();
- hModule = NULL;
+ hModule = nullptr;
return hModule;
}
#ifdef UNICODE
#endif
if (!_InitializeSecurityContext) {
UnloadSecurityDll();
- hModule = NULL;
+ hModule = nullptr;
return hModule;
}
#ifdef UNICODE
#endif
if (!_QuerySecurityPackageInfo) {
UnloadSecurityDll();
- hModule = NULL;
+ hModule = nullptr;
}
#ifdef UNICODE
#endif
if (!_QueryContextAttributes) {
UnloadSecurityDll();
- hModule = NULL;
+ hModule = nullptr;
}
/* Get max token size */
ULONG fContextAttr;
if (!pAS->fInitialized) {
- SecurityStatus = _AcquireCredentialsHandle(NULL, (SEC_CHAR*) _T(SSP_Package_InUse),
- SECPKG_CRED_OUTBOUND, NULL, (NTLM_mode == SSP_NTLM) ? NULL : pAuthIdentity, NULL, NULL,
+ SecurityStatus = _AcquireCredentialsHandle(nullptr, (SEC_CHAR*) _T(SSP_Package_InUse),
+ SECPKG_CRED_OUTBOUND, nullptr, (NTLM_mode == SSP_NTLM) ? NULL : pAuthIdentity, nullptr, nullptr,
&pAS->hcred, &tsExpiry);
if (SecurityStatus < 0)
return FALSE;
sbIn.pvBuffer = pIn;
}
SecurityStatus = _InitializeSecurityContext(&pAS->hcred,
- pAS->fInitialized ? &pAS->hctxt : NULL, NULL, 0, 0,
+ pAS->fInitialized ? &pAS->hctxt : NULL, nullptr, 0, 0,
SECURITY_NATIVE_DREP, pAS->fInitialized ? &sbdIn : NULL,
0, &pAS->hctxt, &sbdOut, &fContextAttr, &tsExpiry);
if (SecurityStatus < 0)
SecPkgContext_Names namebuffer;
if (!pAS->fInitialized) {
- SecurityStatus = _AcquireCredentialsHandle(NULL, (SEC_CHAR*) _T(SSP_Package_InUse),
- SECPKG_CRED_INBOUND, NULL, NULL, NULL, NULL, &pAS->hcred,
+ SecurityStatus = _AcquireCredentialsHandle(nullptr, (SEC_CHAR*) _T(SSP_Package_InUse),
+ SECPKG_CRED_INBOUND, nullptr, nullptr, nullptr, nullptr, &pAS->hcred,
&pAS->hcredLifeTime);
#if SSP_DEBUG
fprintf(stderr, "AcquireCredentialsHandle returned: %x\n", SecurityStatus);
/* Prepare client message (negotiate) */
cbOut = cbMaxToken;
- if (!GenClientContext(&asClient, &ai, NULL, 0, pClientBuf, &cbOut, &fDone))
+ if (!GenClientContext(&asClient, &ai, nullptr, 0, pClientBuf, &cbOut, &fDone))
break;
/* Prepare server message (challenge) */
cbIn = cbOut;
cbOut = cbMaxToken;
if (!GenServerContext(&asServer, pClientBuf, cbIn, pServerBuf, &cbOut,
- &fDone, NULL))
+ &fDone, nullptr))
break;
/* Most likely failure: AcceptServerContext fails with SEC_E_LOGON_DENIED
* in the case of bad szUser or szPassword.
cbIn = cbOut;
cbOut = cbMaxToken;
if (!GenServerContext(&asServer, pClientBuf, cbIn, pServerBuf, &cbOut,
- &fDone, NULL))
+ &fDone, nullptr))
break;
fResult = TRUE;
} while (0);
const char * WINAPI SSP_MakeChallenge(PVOID PNegotiateBuf, int NegotiateLen)
{
BOOL fDone = FALSE;
- uint8_t * fResult = NULL;
+ uint8_t * fResult = nullptr;
DWORD cbOut = 0;
DWORD cbIn = 0;
ntlm_challenge * challenge;
cbIn = NegotiateLen;
cbOut = cbMaxToken;
if (!GenServerContext(&NTLM_asServer, pClientBuf, cbIn, pServerBuf, &cbOut,
- &fDone, NULL))
+ &fDone, nullptr))
break;
fResult = pServerBuf;
} while (0);
encoded[dstLen] = '\0';
return encoded;
}
- return NULL;
+ return nullptr;
}
BOOL WINAPI SSP_ValidateNTLMCredentials(PVOID PAutenticateBuf, int AutenticateLen, char * credentials)
encoded[dstLen] = '\0';
return encoded;
}
- return NULL;
+ return nullptr;
}
const char * WINAPI SSP_ValidateNegotiateCredentials(PVOID PAutenticateBuf, int AutenticateLen, PBOOL fDone, int * Status, char * credentials)
encoded[dstLen] = '\0';
return encoded;
}
- return NULL;
+ return nullptr;
}
#endif /* HAVE_AUTH_MODULE_NEGOTIATE */
buf = aqe->aq_e_buf;
type = aqe->aq_e_type;
callback_valid = cbdataReferenceValidDone(aqe->aq_e_callback_data, &cbdata);
- AIODiskFile * theFile = NULL;
- void *theFileVoid = NULL;
+ AIODiskFile * theFile = nullptr;
+ void *theFileVoid = nullptr;
void *theTmpFile = aqe->theFile;
bool fileOk = cbdataReferenceValidDone(theTmpFile, &theFileVoid);
if ((hndl = CreateFile(path, /* file name */
dwDesiredAccess, /* access mode */
0, /* share mode */
- NULL, /* SD */
+ nullptr, /* SD */
dwCreationDisposition, /* how to create */
FILE_FLAG_OVERLAPPED, /* file attributes */
NULL /* handle to template file */
#else
- openDone(fd, NULL, fd, 0);
+ openDone(fd, nullptr, fd, 0);
#endif
}
#else
- openDone (fd, NULL, fd, 0);
+ openDone (fd, nullptr, fd, 0);
#endif
}
static void squidaio_debug(squidaio_request_t *);
static void squidaio_poll_queues(void);
-static squidaio_thread_t *threads = NULL;
+static squidaio_thread_t *threads = nullptr;
static int squidaio_initialised = 0;
#define AIO_LARGE_BUFS 16384
request_queue2 = {
- NULL, &request_queue2.head
+ nullptr, &request_queue2.head
};
static squidaio_request_queue_t done_queue;
done_requests = {
- NULL, &done_requests.head
+ nullptr, &done_requests.head
};
static HANDLE main_thread;
return squidaio_large_bufs;
}
- return NULL;
+ return nullptr;
}
void *
}
/* Initialize request queue */
- if ((request_queue.mutex = CreateMutex(NULL, /* no inheritance */
+ if ((request_queue.mutex = CreateMutex(nullptr, /* no inheritance */
FALSE, /* start unowned (as per mutex_init) */
- NULL) /* no name */
+ nullptr) /* no name */
) == NULL) {
fatal("Failed to create mutex");
}
- if ((request_queue.cond = CreateEvent(NULL, /* no inheritance */
+ if ((request_queue.cond = CreateEvent(nullptr, /* no inheritance */
FALSE, /* auto signal reset - which I think is pthreads like ? */
FALSE, /* start non signaled */
- NULL) /* no name */
+ nullptr) /* no name */
) == NULL) {
fatal("Failed to create condition variable");
}
- request_queue.head = NULL;
+ request_queue.head = nullptr;
request_queue.tailp = &request_queue.head;
/* Initialize done queue */
- if ((done_queue.mutex = CreateMutex(NULL, /* no inheritance */
+ if ((done_queue.mutex = CreateMutex(nullptr, /* no inheritance */
FALSE, /* start unowned (as per mutex_init) */
- NULL) /* no name */
+ nullptr) /* no name */
) == NULL) {
fatal("Failed to create mutex");
}
- if ((done_queue.cond = CreateEvent(NULL, /* no inheritance */
+ if ((done_queue.cond = CreateEvent(nullptr, /* no inheritance */
TRUE, /* manually signaled - which I think is pthreads like ? */
FALSE, /* start non signaled */
- NULL) /* no name */
+ nullptr) /* no name */
) == NULL) {
fatal("Failed to create condition variable");
}
- done_queue.head = NULL;
+ done_queue.head = nullptr;
done_queue.tailp = &done_queue.head;
for (i = 0; i < NUMTHREADS; ++i) {
threadp = (squidaio_thread_t *)squidaio_thread_pool->alloc();
threadp->status = _THREAD_STARTING;
- threadp->current_req = NULL;
+ threadp->current_req = nullptr;
threadp->requests = 0;
threadp->next = threads;
threads = threadp;
- if ((threadp->thread = CreateThread(NULL, /* no security attributes */
+ if ((threadp->thread = CreateThread(nullptr, /* no security attributes */
0, /* use default stack size */
squidaio_thread_loop, /* thread function */
threadp, /* argument to thread function */
while (1) {
DWORD rv;
- threadp->current_req = request = NULL;
- request = NULL;
+ threadp->current_req = request = nullptr;
+ request = nullptr;
/* Get a request to process */
threadp->status = _THREAD_WAITING;
/* process the request */
threadp->status = _THREAD_BUSY;
- request->next = NULL;
+ request->next = nullptr;
threadp->current_req = request;
request_queue_len += 1;
request->resultp->_data = request;
/* Play some tricks with the request_queue2 queue */
- request->next = NULL;
+ request->next = nullptr;
if (WaitForSingleObject(request_queue.mutex, 0) == WAIT_OBJECT_0) {
if (request_queue2.head) {
if (request_queue2.head) {
/* Clear queue of blocked requests */
- request_queue2.head = NULL;
+ request_queue2.head = nullptr;
request_queue2.tailp = &request_queue2.head;
}
} else {
if (request && request->resultp == resultp) {
debugs(43, 9, "squidaio_cancel: " << request << " type=" << request->request_type << " result=" << request->resultp);
request->cancelled = 1;
- request->resultp = NULL;
- resultp->_data = NULL;
+ request->resultp = nullptr;
+ resultp->_data = nullptr;
resultp->result_type = _AIO_OP_NONE;
return 0;
}
lseek(requestp->fd, requestp->offset, requestp->whence);
if (!ReadFile((HANDLE)_get_osfhandle(requestp->fd), requestp->bufferp,
- requestp->buflen, (LPDWORD)&requestp->ret, NULL)) {
+ requestp->buflen, (LPDWORD)&requestp->ret, nullptr)) {
WIN32_maperror(GetLastError());
requestp->ret = -1;
}
squidaio_do_write(squidaio_request_t * requestp)
{
if (!WriteFile((HANDLE)_get_osfhandle(requestp->fd), requestp->bufferp,
- requestp->buflen, (LPDWORD)&requestp->ret, NULL)) {
+ requestp->buflen, (LPDWORD)&requestp->ret, nullptr)) {
WIN32_maperror(GetLastError());
requestp->ret = -1;
}
}
Sleep(0);
- request_queue2.head = NULL;
+ request_queue2.head = nullptr;
request_queue2.tailp = &request_queue2.head;
}
(WaitForSingleObject(done_queue.mutex, 0)==WAIT_OBJECT_0)) {
struct squidaio_request_t *requests = done_queue.head;
- done_queue.head = NULL;
+ done_queue.head = nullptr;
done_queue.tailp = &done_queue.head;
if (!ReleaseMutex(done_queue.mutex)) {
}
if (!request) {
- return NULL;
+ return nullptr;
}
debugs(43, 9, "squidaio_poll_done: " << request << " type=" << request->request_type << " result=" << request->resultp);
static SC_ACTION Squid_SCAction[] = { { SC_ACTION_RESTART, 60000 } };
static char Squid_ServiceDescriptionString[] = SOFTWARENAME " " VERSION " WWW Proxy Server";
static SERVICE_DESCRIPTION Squid_ServiceDescription = { Squid_ServiceDescriptionString };
-static SERVICE_FAILURE_ACTIONS Squid_ServiceFailureActions = { INFINITE, NULL, NULL, 1, Squid_SCAction };
+static SERVICE_FAILURE_ACTIONS Squid_ServiceFailureActions = { INFINITE, nullptr, nullptr, 1, Squid_SCAction };
static char REGKEY[256] = SOFTWARE "\\" VENDOR "\\" SOFTWARENAME "\\";
static char *keys[] = {
SOFTWAREString, /* key[0] */
VENDORString, /* key[1] */
SOFTWARENAMEString, /* key[2] */
- NULL, /* key[3] */
+ nullptr, /* key[3] */
NULL /* key[4] */
};
unsigned long result;
rv = RegCreateKeyEx(hKey, keys[index], /* subkey */
0, /* reserved */
- NULL, /* class */
- REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hKeyNext, &result);
+ nullptr, /* class */
+ REG_OPTION_NON_VOLATILE, KEY_WRITE, nullptr, &hKeyNext, &result);
if (rv != ERROR_SUCCESS) {
fprintf(stderr, "RegCreateKeyEx(%s),%d\n", keys[index], (int) rv);
WIN32_argv[WIN32_argc++] = word;
}
- WIN32_argv[WIN32_argc] = NULL;
+ WIN32_argv[WIN32_argc] = nullptr;
}
#endif /* USE_WIN32_SERVICE */
NotifyAddrChange = (PFNotifyAddrChange) GetProcAddress(IPHLPAPIHandle, NOTIFYADDRCHANGE);
while (1) {
- Result = NotifyAddrChange(NULL, NULL);
+ Result = NotifyAddrChange(nullptr, nullptr);
if (Result != NO_ERROR) {
debugs(1, DBG_IMPORTANT, "ERROR: NotifyAddrChange error " << Result);
return 1;
DWORD threadID = 0, ThrdParam = 0;
if ((WIN32_run_mode == _WIN_SQUID_RUN_MODE_SERVICE) && (Config.onoff.WIN32_IpAddrChangeMonitor)) {
- NotifyAddrChange_thread = CreateThread(NULL, 0, WIN32_IpAddrChangeMonitor,
+ NotifyAddrChange_thread = CreateThread(nullptr, 0, WIN32_IpAddrChangeMonitor,
&ThrdParam, 0, &threadID);
if (NotifyAddrChange_thread == NULL) {
status = GetLastError();
return 1;
/* Set Process work dir to directory containing squid.exe */
- GetModuleFileName(NULL, path, 512);
+ GetModuleFileName(nullptr, path, 512);
WIN32_module_name=xstrdup(path);
DWORD Type = 0;
DWORD Size = 0;
LONG Result;
- Result = RegQueryValueEx(hndKey, CONFIGFILE, NULL, &Type, NULL, &Size);
+ Result = RegQueryValueEx(hndKey, CONFIGFILE, nullptr, &Type, nullptr, &Size);
if (Result == ERROR_SUCCESS && Size) {
ConfigFile = static_cast<char *>(xmalloc(Size));
- RegQueryValueEx(hndKey, CONFIGFILE, NULL, &Type, (unsigned char *)ConfigFile, &Size);
+ RegQueryValueEx(hndKey, CONFIGFILE, nullptr, &Type, (unsigned char *)ConfigFile, &Size);
} else
ConfigFile = xstrdup(DEFAULT_CONFIG_FILE);
Type = 0;
- Result = RegQueryValueEx(hndKey, COMMANDLINE, NULL, &Type, NULL, &Size);
+ Result = RegQueryValueEx(hndKey, COMMANDLINE, nullptr, &Type, nullptr, &Size);
if (Result == ERROR_SUCCESS && Size) {
WIN32_Service_Command_Line = static_cast<char *>(xmalloc(Size));
- RegQueryValueEx(hndKey, COMMANDLINE, NULL, &Type, (unsigned char *)WIN32_Service_Command_Line, &Size);
+ RegQueryValueEx(hndKey, COMMANDLINE, nullptr, &Type, (unsigned char *)WIN32_Service_Command_Line, &Size);
} else
WIN32_Service_Command_Line = xstrdup("");
keys[4] = const_cast<char*>(service);
- schSCManager = OpenSCManager(NULL, /* machine (NULL == local) */
- NULL, /* database (NULL == default) */
+ schSCManager = OpenSCManager(nullptr, /* machine (NULL == local) */
+ nullptr, /* database (NULL == default) */
SC_MANAGER_ALL_ACCESS /* access required */
);
keys[4] = const_cast<char*>(service);
- if ((lenpath = GetModuleFileName(NULL, ServicePath, 512)) == 0) {
+ if ((lenpath = GetModuleFileName(nullptr, ServicePath, 512)) == 0) {
fprintf(stderr, "Can't get executable path\n");
exit(EXIT_FAILURE);
}
snprintf(szPath, sizeof(szPath), "%s %s:" SQUIDSBUFPH, ServicePath, _WIN_SQUID_SERVICE_OPTION, SQUIDSBUFPRINT(service_name));
- schSCManager = OpenSCManager(NULL, /* machine (NULL == local) */
- NULL, /* database (NULL == default) */
+ schSCManager = OpenSCManager(nullptr, /* machine (NULL == local) */
+ nullptr, /* database (NULL == default) */
SC_MANAGER_ALL_ACCESS /* access required */
);
SERVICE_AUTO_START, /* start type */
SERVICE_ERROR_NORMAL, /* error control type */
(const char *) szPath, /* service's binary */
- NULL, /* no load ordering group */
- NULL, /* no tag identifier */
+ nullptr, /* no load ordering group */
+ nullptr, /* no tag identifier */
"Tcpip\0AFD\0", /* dependencies */
- NULL, /* LocalSystem account */
- NULL); /* no password */
+ nullptr, /* LocalSystem account */
+ nullptr); /* no password */
if (schService) {
if (WIN32_OS_version > _WIN_OS_WINNT) {
if (service_name.isEmpty())
service_name = SBuf(APP_SHORTNAME);
- schSCManager = OpenSCManager(NULL, /* machine (NULL == local) */
- NULL, /* database (NULL == default) */
+ schSCManager = OpenSCManager(nullptr, /* machine (NULL == local) */
+ nullptr, /* database (NULL == default) */
SC_MANAGER_ALL_ACCESS /* access required */
);
int WIN32_StartService(int argc, char **argv)
{
SERVICE_TABLE_ENTRY DispatchTable[] = {
- {NULL, SquidWinSvcMain},
- {NULL, NULL}
+ {nullptr, SquidWinSvcMain},
+ {nullptr, nullptr}
};
char *c;
char stderr_path[256];
pid_t mypid;
char *machinedomain;
int use_case_insensitive_compare = 0;
-char *DefaultDomain = NULL;
+char *DefaultDomain = nullptr;
const char NTV_VALID_DOMAIN_SEPARATOR[] = "\\/";
int numberofgroups = 0;
int WIN32_COM_initialized = 0;
-char *WIN32_ErrorMessage = NULL;
+char *WIN32_ErrorMessage = nullptr;
wchar_t **User_Groups;
int User_Groups_Count = 0;
VARIANT var;
unsigned User_primaryGroupID;
char tmpSID[SECURITY_MAX_SID_SIZE * 2];
- wchar_t *wc = NULL, *result = NULL;
+ wchar_t *wc = nullptr, *result = nullptr;
int wcsize;
VariantInit(&var);
hr = pUser->lpVtbl->Get(pUser, L"objectSid", &var);
if (SUCCEEDED(hr)) {
PSID pObjectSID;
- LPBYTE pByte = NULL;
- char *szSID = NULL;
+ LPBYTE pByte = nullptr;
+ char *szSID = nullptr;
hr = GetLPBYTEtoOctetString(&var, &pByte);
pObjectSID = (PSID) pByte;
{
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
- NULL,
+ nullptr,
hr,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPTSTR) & WIN32_ErrorMessage,
0,
- NULL);
+ nullptr);
return WIN32_ErrorMessage;
}
WIN32_COM_initialized = 1;
}
hr = CoCreateInstance(&CLSID_NameTranslate,
- NULL,
+ nullptr,
CLSCTX_INPROC_SERVER,
&IID_IADsNameTranslate,
(void **) &pNto);
if (FAILED(hr)) {
debug("My_NameTranslate: cannot set translate of %S, ERROR: %s\n", name, Get_WIN32_ErrorMessage(hr));
pNto->lpVtbl->Release(pNto);
- return NULL;
+ return nullptr;
}
hr = pNto->lpVtbl->Get(pNto, out_format, &bstr);
if (FAILED(hr)) {
debug("My_NameTranslate: cannot get translate of %S, ERROR: %s\n", name, Get_WIN32_ErrorMessage(hr));
pNto->lpVtbl->Release(pNto);
- return NULL;
+ return nullptr;
}
debug("My_NameTranslate: %S translated to %S\n", name, bstr);
char *
GetDomainName(void)
{
- static char *DomainName = NULL;
+ static char *DomainName = nullptr;
PDSROLE_PRIMARY_DOMAIN_INFO_BASIC pDSRoleInfo;
DWORD netret;
- if ((netret = DsRoleGetPrimaryDomainInformation(NULL, DsRolePrimaryDomainInfoBasic, (PBYTE *) & pDSRoleInfo) == ERROR_SUCCESS)) {
+ if ((netret = DsRoleGetPrimaryDomainInformation(nullptr, DsRolePrimaryDomainInfoBasic, (PBYTE *) & pDSRoleInfo) == ERROR_SUCCESS)) {
/*
* Check the machine role.
*/
DomainName = (char *) xmalloc(len + 1);
/* copy unicode buffer */
- WideCharToMultiByte(CP_ACP, 0, pDSRoleInfo->DomainNameFlat, -1, DomainName, len, NULL, NULL);
+ WideCharToMultiByte(CP_ACP, 0, pDSRoleInfo->DomainNameFlat, -1, DomainName, len, nullptr, nullptr);
/* add null termination */
DomainName[len] = '\0';
if (User_Groups_Count == 0) {
User_Groups = (wchar_t **) xmalloc(sizeof(wchar_t *));
- *User_Groups = NULL;
+ *User_Groups = nullptr;
++User_Groups_Count;
}
array = User_Groups;
++array;
}
User_Groups = (wchar_t **) xrealloc(User_Groups, sizeof(wchar_t *) * (User_Groups_Count + 1));
- User_Groups[User_Groups_Count] = NULL;
+ User_Groups[User_Groups_Count] = nullptr;
User_Groups[User_Groups_Count - 1] = (wchar_t *) xmalloc((wcslen(Group) + 1) * sizeof(wchar_t));
wcscpy(User_Groups[User_Groups_Count - 1], Group);
++User_Groups_Count;
static wchar_t **
build_groups_DN_array(const char **array, char *userdomain)
{
- wchar_t *wc = NULL;
+ wchar_t *wc = nullptr;
int wcsize;
int source_group_format;
char Group[GNLEN + 1];
}
++entry;
}
- *entry = NULL;
+ *entry = nullptr;
return wc_array;
}
NET_API_STATUS nStatus;
DWORD i;
DWORD dwTotalCount = 0;
- LPBYTE pBufTmp = NULL;
+ LPBYTE pBufTmp = nullptr;
if ((Domain_Separator = strchr(UserName, '/')) != NULL)
*Domain_Separator = '\\';
* function should also return the names of the local
* groups in which the user is indirectly a member.
*/
- nStatus = NetUserGetLocalGroups(NULL,
+ nStatus = NetUserGetLocalGroups(nullptr,
wszUserName,
dwLevel,
dwFlags,
WCHAR wszUser[DNLEN + UNLEN + 2]; /* Unicode user name */
char NTDomain[DNLEN + UNLEN + 2];
- char *domain_qualify = NULL;
+ char *domain_qualify = nullptr;
char User[DNLEN + UNLEN + 2];
size_t j;
}
mypid = getpid();
- setbuf(stdout, NULL);
- setbuf(stderr, NULL);
+ setbuf(stdout, nullptr);
+ setbuf(stderr, nullptr);
/* Check Command Line */
process_options(argc, argv);
continue;
}
username = strtok(buf, " ");
- for (n = 0; (group = strtok(NULL, " ")) != NULL; ++n) {
+ for (n = 0; (group = strtok(nullptr, " ")) != NULL; ++n) {
rfc1738_unescape(group);
groups[n] = group;
}
- groups[n] = NULL;
+ groups[n] = nullptr;
numberofgroups = n;
if (NULL == username) {
typedef WINLDAPAPI ULONG(LDAPAPI * PFldap_start_tls_s) (IN PLDAP, OUT PULONG, OUT LDAPMessage **, IN PLDAPControlA *, IN PLDAPControlA *);
#endif /* LDAP_UNICODE */
PFldap_start_tls_s Win32_ldap_start_tls_s;
-#define ldap_start_tls_s(l,s,c) Win32_ldap_start_tls_s(l,NULL,NULL,s,c)
+#define ldap_start_tls_s(l,s,c) Win32_ldap_start_tls_s(l, nullptr, nullptr,s,c)
#endif /* LDAP_VERSION3 */
#else
static int noreferrals = 0;
static int aliasderef = LDAP_DEREF_NEVER;
#if defined(NETSCAPE_SSL)
-static char *sslpath = NULL;
+static char *sslpath = nullptr;
static int sslinit = 0;
#endif
static int connect_timeout = 0;
#endif
#if NETSCAPE_SSL
if (sslpath) {
- if (!sslinit && (ldapssl_client_init(sslpath, NULL) != LDAP_SUCCESS)) {
+ if (!sslinit && (ldapssl_client_init(sslpath, nullptr) != LDAP_SUCCESS)) {
fprintf(stderr, "FATAL: Unable to initialise SSL with cert path %s\n", sslpath);
exit(EXIT_FAILURE);
} else {
pid_t mypid;
char *machinedomain;
int use_case_insensitive_compare = 0;
-char *DefaultDomain = NULL;
+char *DefaultDomain = nullptr;
const char NTV_VALID_DOMAIN_SEPARATOR[] = "\\/";
char *
safe_free(target);
target = (char *) xmalloc(len);
if (target == NULL)
- return NULL;
+ return nullptr;
/* copy unicode buffer */
- WideCharToMultiByte(CP_ACP, 0, LsaStr.Buffer, LsaStr.Length, target, len, NULL, NULL);
+ WideCharToMultiByte(CP_ACP, 0, LsaStr.Buffer, LsaStr.Length, target, len, nullptr, nullptr);
/* add null termination */
target[len - 1] = '\0';
PPOLICY_PRIMARY_DOMAIN_INFO ppdiDomainInfo;
PWKSTA_INFO_100 pwkiWorkstationInfo;
DWORD netret;
- char *DomainName = NULL;
+ char *DomainName = nullptr;
/*
* Always initialize the object attributes to all zeroes.
* The wki100_computername field contains a pointer to a UNICODE
* string containing the local computer name.
*/
- netret = NetWkstaGetInfo(NULL, 100, (LPBYTE *) & pwkiWorkstationInfo);
+ netret = NetWkstaGetInfo(nullptr, 100, (LPBYTE *) & pwkiWorkstationInfo);
if (netret == NERR_Success) {
/*
* We have the workstation name in:
* the LsaOpenPolicy function.
*/
status = LsaOpenPolicy(
- NULL,
+ nullptr,
&ObjectAttributes,
GENERIC_READ | POLICY_VIEW_LOCAL_INFORMATION,
&PolicyHandle
*/
debug("Member of Domain %s\n", DomainName);
} else {
- DomainName = NULL;
+ DomainName = nullptr;
}
}
}
char *Domain_Separator;
WCHAR wszUserName[UNLEN + 1]; // Unicode user name
- LPLOCALGROUP_USERS_INFO_0 pBuf = NULL;
+ LPLOCALGROUP_USERS_INFO_0 pBuf = nullptr;
LPLOCALGROUP_USERS_INFO_0 pTmpBuf;
DWORD dwLevel = 0;
DWORD dwFlags = LG_INCLUDE_INDIRECT;
* groups in which the user is indirectly a member.
*/
nStatus = NetUserGetLocalGroups(
- NULL,
+ nullptr,
wszUserName,
dwLevel,
dwFlags,
char User[UNLEN + 1];
size_t j;
- LPWSTR LclDCptr = NULL;
- LPWSTR UsrDCptr = NULL;
- LPGROUP_USERS_INFO_0 pUsrBuf = NULL;
+ LPWSTR LclDCptr = nullptr;
+ LPWSTR UsrDCptr = nullptr;
+ LPGROUP_USERS_INFO_0 pUsrBuf = nullptr;
LPGROUP_USERS_INFO_0 pTmpBuf;
- LPSERVER_INFO_101 pSrvBuf = NULL;
+ LPSERVER_INFO_101 pSrvBuf = nullptr;
DWORD dwLevel = 0;
DWORD dwPrefMaxLen = -1;
DWORD dwEntriesRead = 0;
/* Call the NetServerGetInfo function for local computer, specifying level 101. */
dwLevel = 101;
- nStatus = NetServerGetInfo(NULL, dwLevel, (LPBYTE *) & pSrvBuf);
+ nStatus = NetServerGetInfo(nullptr, dwLevel, (LPBYTE *) & pSrvBuf);
if (nStatus == NERR_Success) {
/* Check if we are running on a Domain Controller */
if ((pSrvBuf->sv101_type & SV_TYPE_DOMAIN_CTRL) ||
(pSrvBuf->sv101_type & SV_TYPE_DOMAIN_BAKCTRL)) {
- LclDCptr = NULL;
+ LclDCptr = nullptr;
debug("Running on a DC.\n");
} else
- nStatus = (use_PDC_only ? NetGetDCName(NULL, wszLocalDomain, (LPBYTE *) & LclDCptr) : NetGetAnyDCName(NULL, wszLocalDomain, (LPBYTE *) & LclDCptr));
+ nStatus = (use_PDC_only ? NetGetDCName(nullptr, wszLocalDomain, (LPBYTE *) & LclDCptr) : NetGetAnyDCName(nullptr, wszLocalDomain, (LPBYTE *) & LclDCptr));
} else {
fprintf(stderr, "%s: ERROR: NetServerGetInfo() failed.'\n", program_name);
if (pSrvBuf != NULL)
}
mypid = getpid();
- setbuf(stdout, NULL);
- setbuf(stderr, NULL);
+ setbuf(stdout, nullptr);
+ setbuf(stderr, nullptr);
/* Check Command Line */
process_options(argc, argv);
continue;
}
username = strtok(buf, " ");
- for (n = 0; (group = strtok(NULL, " ")) != NULL; ++n) {
+ for (n = 0; (group = strtok(nullptr, " ")) != NULL; ++n) {
rfc1738_unescape(group);
groups[n] = group;
}
- groups[n] = NULL;
+ groups[n] = nullptr;
if (NULL == username) {
SEND_BH(HLP_MSG("Invalid Request. No Username."));
local_printfx("BH message=\"(SearchFilterLDAP: %s)\"\n", ErrLDAP(x));
} else {
edui_ldap.err = -1;
- debug("SearchFilterLDAP(-, NULL) -> Length: %u\n", x);
+ debug("SearchFilterLDAP(-, nullptr) -> Length: %u\n", x);
x = SearchLDAP(&edui_ldap, edui_ldap.scope, edui_ldap.search_filter, (char **) &search_attrib);
if (x != LDAP_ERR_SUCCESS) {
debug("SearchLDAP() -> %s (LDAP: %s)\n", ErrLDAP(x), ldap_err2string(x));
creds->client = principal;
code = krb5_parse_name(kparam.context, service, &creds->server);
xfree(service);
- code = krb5_get_in_tkt_with_keytab(kparam.context, 0, NULL, NULL, NULL, keytab, NULL, creds, 0);
+ code = krb5_get_in_tkt_with_keytab(kparam.context, 0, nullptr, nullptr, nullptr, keytab, nullptr, creds, 0);
#endif
if (code) {
creds->client = principal_list[i];
code = krb5_parse_name(kparam.context, service, &creds->server);
xfree(service);
- code = krb5_get_in_tkt_with_keytab(kparam.context, 0, NULL, NULL, NULL, keytab, NULL, creds, 0);
+ code = krb5_get_in_tkt_with_keytab(kparam.context, 0, nullptr, nullptr, nullptr, keytab, nullptr, creds, 0);
#endif
if (code) {
k5_error("Error while initialising credentials from keytab", code);
credp = credp;
methodp = methodp;
freeit = freeit;
- return ldap_sasl_bind_s(ld, cp->dn, LDAP_SASL_SIMPLE, &cred, NULL, NULL,
- NULL);
+ return ldap_sasl_bind_s(ld, cp->dn, LDAP_SASL_SIMPLE, &cred, nullptr, nullptr,
+ nullptr);
}
#elif HAVE_LDAP_REBIND_PROC
#if HAVE_SASL_H || HAVE_SASL_SASL_H || HAVE_SASL_DARWIN
cred.bv_val = cp->pw;
cred.bv_len = strlen(cp->pw);
}
- return ldap_sasl_bind_s(ld, cp->dn, LDAP_SASL_SIMPLE, &cred, NULL, NULL,
- NULL);
+ return ldap_sasl_bind_s(ld, cp->dn, LDAP_SASL_SIMPLE, &cred, nullptr, nullptr,
+ nullptr);
}
#elif HAVE_LDAP_REBIND_FUNCTION
credp = credp;
methodp = methodp;
freeit = freeit;
- return ldap_sasl_bind_s(ld, cp->dn, LDAP_SASL_SIMPLE, &cred, NULL, NULL,
- NULL);
+ return ldap_sasl_bind_s(ld, cp->dn, LDAP_SASL_SIMPLE, &cred, nullptr, nullptr,
+ nullptr);
}
#else
#error "No rebind functione defined"
#if HAVE_OPENLDAP
int val;
#elif HAVE_LDAPSSL_CLIENT_INIT
- char *ssl_certdbpath = NULL;
+ char *ssl_certdbpath = nullptr;
#endif
#if HAVE_OPENLDAP
* Solaris SSL ldap calls require path to certificate database
*/
/*
- * rc = ldapssl_client_init( ssl_certdbpath, NULL );
- * rc = ldapssl_advclientauth_init( ssl_certdbpath, NULL , 0 , NULL, NULL, 0, NULL, 2);
+ * rc = ldapssl_client_init( ssl_certdbpath, nullptr);
+ * rc = ldapssl_advclientauth_init( ssl_certdbpath, nullptr, 0 , nullptr, nullptr, 0, nullptr, 2);
*/
ssl_certdbpath = getenv("SSL_CERTDBPATH");
if (!ssl_certdbpath) {
"%s| %s: DEBUG: Set certificate database path for ldap server to %s. (Changeable through setting environment variable SSL_CERTDBPATH)\n",
LogTime(), PROGRAM, ssl_certdbpath);
if (!margs->rc_allow) {
- rc = ldapssl_advclientauth_init(ssl_certdbpath, NULL, 0, NULL, NULL, 0,
- NULL, 2);
+ rc = ldapssl_advclientauth_init(ssl_certdbpath, nullptr, 0, nullptr, nullptr, 0,
+ nullptr, 2);
} else {
- rc = ldapssl_advclientauth_init(ssl_certdbpath, NULL, 0, NULL, NULL, 0,
- NULL, 0);
+ rc = ldapssl_advclientauth_init(ssl_certdbpath, nullptr, 0, nullptr, nullptr, 0,
+ nullptr, 0);
debug((char *)
"%s| %s: DEBUG: Disable server certificate check for ldap server.\n",
LogTime(), PROGRAM);
LogTime(), PROGRAM, ldap_err2string(rc));
xfree(ldapuri);
ldap_free_urldesc(url);
- return NULL;
+ return nullptr;
}
#else
#error "No URL parsing function"
LogTime(), PROGRAM, ldap_err2string(rc));
xfree(ldapuri);
ldap_free_urldesc(url);
- return NULL;
+ return nullptr;
}
#else
#error "No URL parsing function"
error((char *)
"%s| %s: ERROR: Error while setting SSL for ldap server: %s\n",
LogTime(), PROGRAM, ldapssl_err2string(rc));
- ldap_unbind_ext(ld, NULL, NULL);
- ld = NULL;
- return NULL;
+ ldap_unbind_ext(ld, nullptr, nullptr);
+ ld = nullptr;
+ return nullptr;
}
rc = ldap_set_defaults(ld);
if (rc != LDAP_SUCCESS) {
error((char *)
"%s| %s: ERROR: Error while setting default options for ldap server: %s\n",
LogTime(), PROGRAM, ldap_err2string(rc));
- ldap_unbind_ext(ld, NULL, NULL);
- ld = NULL;
- return NULL;
+ ldap_unbind_ext(ld, nullptr, nullptr);
+ ld = nullptr;
+ return nullptr;
}
#else
error((char *) "%s| %s: ERROR: SSL not supported by ldap library\n",
break;
}
#else
- ldap_unbind_ext(ld, NULL, NULL);
- ld = NULL;
+ ldap_unbind_ext(ld, nullptr, nullptr);
+ ld = nullptr;
error((char *) "%s| %s: ERROR: SASL not supported on system\n",
LogTime(), PROGRAM);
continue;
char *sasl_secprops;
/*
* char *sasl_secprops = (char *)"maxssf=56";
- * char *sasl_secprops = NULL;
+ * char *sasl_secprops = nullptr;
*/
struct berval passwd = {};
void *defaults;
if ((username = strtok(line, "\t ")) != NULL) {
/* get the time budget */
- if ((budget = strtok(NULL, "/")) == NULL) {
+ if ((budget = strtok(nullptr, "/")) == NULL) {
fprintf(stderr, "ERROR: missing 'budget' field on line %u of '%s'.\n", lineCount, filename);
continue;
}
- if ((period = strtok(NULL, "/")) == NULL) {
+ if ((period = strtok(nullptr, "/")) == NULL) {
fprintf(stderr, "ERROR: missing 'period' field on line %u of '%s'.\n", lineCount, filename);
continue;
}
}
log_info("Starting %s\n", __FILE__);
- setbuf(stdout, NULL);
+ setbuf(stdout, nullptr);
init_db();
typedef WINLDAPAPI ULONG(LDAPAPI * PFldap_start_tls_s) (IN PLDAP, OUT PULONG, OUT LDAPMessage **, IN PLDAPControlA *, IN PLDAPControlA *);
#endif /* LDAP_UNICODE */
PFldap_start_tls_s Win32_ldap_start_tls_s;
-#define ldap_start_tls_s(l,s,c) Win32_ldap_start_tls_s(l,NULL,NULL,s,c)
+#define ldap_start_tls_s(l,s,c) Win32_ldap_start_tls_s(l, nullptr, nullptr,s,c)
#endif /* LDAP_VERSION3 */
#else
static int noreferrals = 0;
static int aliasderef = LDAP_DEREF_NEVER;
#if defined(NETSCAPE_SSL)
-static const char *sslpath = NULL;
+static const char *sslpath = nullptr;
static int sslinit = 0;
#endif
static int connect_timeout = 0;
#endif
#if NETSCAPE_SSL
if (sslpath) {
- if (!sslinit && (ldapssl_client_init(sslpath, NULL) != LDAP_SUCCESS)) {
+ if (!sslinit && (ldapssl_client_init(sslpath, nullptr) != LDAP_SUCCESS)) {
fprintf(stderr, "\nUnable to initialise SSL with cert path %s\n",
sslpath);
exit(EXIT_FAILURE);
#endif
#if _SQUID_SOLARIS_
-static char *password = NULL; /* Workaround for Solaris 2.6 brokenness */
+static char *password = nullptr; /* Workaround for Solaris 2.6 brokenness */
#endif
extern "C" int password_conversation(int num_msg, PAM_CONV_FUNC_CONST_PARM struct pam_message **msg,
int
main(int argc, char *argv[])
{
- pam_handle_t *pamh = NULL;
+ pam_handle_t *pamh = nullptr;
int retval = PAM_SUCCESS;
char *user;
char *password_buf;
int no_realm = 0;
/* make standard output line buffered */
- setvbuf(stdout, NULL, _IOLBF, 0);
+ setvbuf(stdout, nullptr, _IOLBF, 0);
while (1) {
int ch = getopt(argc, argv, "1n:t:or");
if (retval != PAM_SUCCESS) {
debug("WARNING: failed to release PAM authenticator\n");
}
- pamh = NULL;
+ pamh = nullptr;
}
/* Initialize persistent PAM connection */
retval = pam_start(service, "squid@", &conv, &pamh);
retval = PAM_SUCCESS;
#if defined(PAM_AUTHTOK)
if (ttl != 0 && pamh) {
- retval = pam_set_item(pamh, PAM_AUTHTOK, NULL);
+ retval = pam_set_item(pamh, PAM_AUTHTOK, nullptr);
}
#endif
if (pamh && (ttl == 0 || retval != PAM_SUCCESS)) {
if (retval != PAM_SUCCESS) {
debug("WARNING: failed to release PAM authenticator\n");
}
- pamh = NULL;
+ pamh = nullptr;
}
}
if (pamh) {
retval = pam_end(pamh, retval);
if (retval != PAM_SUCCESS) {
- pamh = NULL;
+ pamh = nullptr;
debug("ERROR: failed to release PAM authenticator\n");
}
}
}
#if SASL_VERSION_MAJOR < 2
- rc = sasl_server_new( APP_NAME_SASL, NULL, NULL, NULL, 0, &conn );
+ rc = sasl_server_new( APP_NAME_SASL, nullptr, nullptr, nullptr, 0, &conn );
#else
rc = sasl_server_new( APP_NAME_SASL, nullptr, nullptr, nullptr, nullptr, nullptr, 0, &conn );
#endif
debug("errstr %s\n", errstr);
}
if ( rc != SASL_BADAUTH ) {
- debug("ERROR: %d %s\n", rc, sasl_errstring(rc, NULL, NULL));
- SEND_ERR(sasl_errstring(rc, NULL, NULL));
+ debug("ERROR: %d %s\n", rc, sasl_errstring(rc, nullptr, nullptr));
+ SEND_ERR(sasl_errstring(rc, nullptr, nullptr));
} else
#endif
SEND_ERR("");
{
for (domaincontrollers_t::iterator dc = domaincontrollers.begin(); dc != domaincontrollers.end(); ++dc) {
//std::cerr << "testing against " << dc->server << std::endl;
- const int rv = Valid_User(username, password, dc->server.c_str(), NULL, dc->domain.c_str());
+ const int rv = Valid_User(username, password, dc->server.c_str(), nullptr, dc->domain.c_str());
//std::cerr << "check result: " << rv << std::endl;
if (rv == NTV_NO_ERROR)
return true;
int err = 0;
openlog("basic_smb_lm_auth", LOG_PID, LOG_USER);
- setbuf(stdout, NULL);
+ setbuf(stdout, nullptr);
for (int j = 1; j < argc; ++j) {
std::string arg = argv[j];
SMB_Handle_Type con;
SMB_Init();
- con = SMB_Connect_Server(NULL, SERVER, DOMAIN);
+ con = SMB_Connect_Server(nullptr, SERVER, DOMAIN);
if (con == NULL) {
return (NTV_SERVER_ERROR);
}
SMB_Discon(con, 0);
return (NTV_PROTOCOL_ERROR);
}
- if (SMB_Logon_Server(con, USERNAME, PASSWORD, NULL, 0) < 0) {
+ if (SMB_Logon_Server(con, USERNAME, PASSWORD, nullptr, 0) < 0) {
SMB_Discon(con, 0);
return (NTV_LOGON_ERROR);
}
atexit(UnloadSecurityDll);
/* initialize FDescs */
- setbuf(stdout, NULL);
- setbuf(stderr, NULL);
+ setbuf(stdout, nullptr);
+ setbuf(stderr, nullptr);
while (fgets(wstr, HELPER_INPUT_BUFFER, stdin) != NULL) {
WCHAR wszUserName[256]; // Unicode user name
WCHAR wszGroup[256]; // Unicode Group
- LPLOCALGROUP_USERS_INFO_0 pBuf = NULL;
+ LPLOCALGROUP_USERS_INFO_0 pBuf = nullptr;
LPLOCALGROUP_USERS_INFO_0 pTmpBuf;
DWORD dwLevel = 0;
DWORD dwFlags = LG_INCLUDE_INDIRECT;
* function should also return the names of the local
* groups in which the user is indirectly a member.
*/
- nStatus = NetUserGetLocalGroups(NULL,
+ nStatus = NetUserGetLocalGroups(nullptr,
wszUserName,
dwLevel,
dwFlags,
int result = NTV_SERVER_ERROR;
size_t i;
char NTDomain[256];
- char *domain_qualify = NULL;
+ char *domain_qualify = nullptr;
char DomainUser[256];
char User[256];
typedef WINLDAPAPI ULONG(LDAPAPI * PFldap_start_tls_s) (IN PLDAP, OUT PULONG, OUT LDAPMessage **, IN PLDAPControlA *, IN PLDAPControlA *);
#endif /* LDAP_UNICODE */
PFldap_start_tls_s Win32_ldap_start_tls_s;
-#define ldap_start_tls_s(l,s,c) Win32_ldap_start_tls_s(l,NULL,NULL,s,c)
+#define ldap_start_tls_s(l,s,c) Win32_ldap_start_tls_s(l, nullptr, nullptr,s,c)
#endif /* LDAP_VERSION3 */
#else
static int strip_nt_domain = 0;
static int aliasderef = LDAP_DEREF_NEVER;
#if defined(NETSCAPE_SSL)
-static char *sslpath = NULL;
+static char *sslpath = nullptr;
static int sslinit = 0;
#endif
static int connect_timeout = 0;
#endif
#if NETSCAPE_SSL
if (sslpath) {
- if (!sslinit && (ldapssl_client_init(sslpath, NULL) != LDAP_SUCCESS)) {
+ if (!sslinit && (ldapssl_client_init(sslpath, nullptr) != LDAP_SUCCESS)) {
fprintf(stderr, "\nUnable to initialise SSL with cert path %s\n",
sslpath);
exit(EXIT_FAILURE);
#else
fprintf(stderr, "TLS not supported with your LDAP library\n");
ldap_unbind(ld);
- ld = NULL;
+ ld = nullptr;
#endif
}
#endif
typedef WINLDAPAPI ULONG(LDAPAPI * PFldap_start_tls_s) (IN PLDAP, OUT PULONG, OUT LDAPMessage **, IN PLDAPControlA *, IN PLDAPControlA *);
#endif /* LDAP_UNICODE */
PFldap_start_tls_s Win32_ldap_start_tls_s;
-#define ldap_start_tls_s(l,s,c) Win32_ldap_start_tls_s(l,NULL,NULL,s,c)
+#define ldap_start_tls_s(l,s,c) Win32_ldap_start_tls_s(l, nullptr, nullptr,s,c)
#endif /* LDAP_VERSION3 */
#else
static int edir_universal_passwd = 0;
static int aliasderef = LDAP_DEREF_NEVER;
#if defined(NETSCAPE_SSL)
-static char *sslpath = NULL;
+static char *sslpath = nullptr;
static int sslinit = 0;
#endif
static int connect_timeout = 0;
#endif
#if NETSCAPE_SSL
if (sslpath) {
- if (!sslinit && (ldapssl_client_init(sslpath, NULL) != LDAP_SUCCESS)) {
+ if (!sslinit && (ldapssl_client_init(sslpath, nullptr) != LDAP_SUCCESS)) {
fprintf(stderr, "\nUnable to initialise SSL with cert path %s\n",
sslpath);
exit(EXIT_FAILURE);
#else
fprintf(stderr, "TLS not supported with your LDAP library\n");
ldap_unbind(ld);
- ld = NULL;
+ ld = nullptr;
#endif
}
#endif
* -d enable debugging.
* -v enable verbose Negotiate packet debugging.
*/
-char *my_program_name = NULL;
+char *my_program_name = nullptr;
void
usage()
if (status == SSP_ERROR) {
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
- NULL,
+ nullptr,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), /* Default language */
(LPTSTR) & ErrorMessage,
0,
- NULL);
+ nullptr);
if (ErrorMessage[strlen(ErrorMessage) - 1] == '\n')
ErrorMessage[strlen(ErrorMessage) - 1] = '\0';
if (ErrorMessage[strlen(ErrorMessage) - 1] == '\r')
atexit(UnloadSecurityDll);
/* initialize FDescs */
- setbuf(stdout, NULL);
- setbuf(stderr, NULL);
+ setbuf(stdout, nullptr);
+ setbuf(stderr, nullptr);
while (manage_request()) {
/* everything is done within manage_request */
int
main(int argc, char *const argv[])
{
- setbuf(stdout, NULL);
- setbuf(stdin, NULL);
+ setbuf(stdout, nullptr);
+ setbuf(stdin, nullptr);
char buf[MAX_AUTHTOKEN_LEN];
while (1) {
if (fgets(buf, sizeof(buf) - 1, stdin) == NULL) {
static unsigned char challenge[NTLM_NONCE_LEN];
static unsigned char lmencoded_empty_pass[ENCODED_PASS_LEN],
ntencoded_empty_pass[ENCODED_PASS_LEN];
-SMB_Handle_Type handle = NULL;
+SMB_Handle_Type handle = nullptr;
int ntlm_errno;
static char credentials[MAX_USERNAME_LEN+MAX_DOMAIN_LEN+2]; /* we can afford to waste */
static char my_domain[100], my_domain_controller[100];
char error_messages_buffer[NTLM_BLOB_BUFFER_SIZE];
#endif
char load_balance = 0, protocol_pedantic = 0;
-dc *controllers = NULL;
+dc *controllers = nullptr;
int numcontrollers = 0;
dc *current_dc;
char smb_error_buffer[1000];
{
if (handle != NULL)
SMB_Discon(handle, 0);
- handle = NULL;
+ handle = nullptr;
}
int
int
is_dc_ok(char *domain, char *domain_controller)
{
- SMB_Handle_Type h = SMB_Connect_Server(NULL, domain_controller, domain);
+ SMB_Handle_Type h = SMB_Connect_Server(nullptr, domain_controller, domain);
if (h == NULL)
return 0;
SMB_Discon(h, 0);
return 0;
}
debug("Connecting to server %s domain %s\n", domain_controller, domain);
- handle = SMB_Connect_Server(NULL, domain_controller, domain);
+ handle = SMB_Connect_Server(nullptr, domain_controller, domain);
smberr = SMB_Get_Last_Error();
SMB_Get_Error_Msg(smberr, errstr, 1000);
if (SMB_Negotiate(handle, SMB_Prots) < 0) { /* An error */
debug("Error negotiating protocol with SMB Server\n");
SMB_Discon(handle, 0);
- handle = NULL;
+ handle = nullptr;
return 2;
}
if (handle->Security == 0) { /* share-level security, unusable */
debug("SMB Server uses share-level security .. we need user security.\n");
SMB_Discon(handle, 0);
- handle = NULL;
+ handle = nullptr;
return 3;
}
memcpy(challenge, handle->Encrypt_Key, NTLM_NONCE_LEN);
my_domain_controller[sizeof(my_domain_controller)-1] = '\0';
if (init_challenge(my_domain, my_domain_controller) > 0) {
- return NULL;
+ return nullptr;
}
ntlm_challenge chal;
static char b64buf[HELPER_INPUT_BUFFER-10]; /* 10 for other line fields, delimiters and terminator */
if (base64_encode_len(len) < sizeof(b64buf)-1) {
debug("base64 encoding of the token challenge will exceed %zu bytes", sizeof(b64buf));
- return NULL;
+ return nullptr;
}
struct base64_encode_ctx ctx;
if (handle == NULL) { /*if null we aren't connected, but it shouldn't happen */
debug("Weird, we've been disconnected\n");
ntlm_errno = NTLM_ERR_NOT_CONNECTED;
- return NULL;
+ return nullptr;
}
/* debug("fetching domain\n"); */
if (tmp.str == NULL || tmp.l == 0) {
debug("No domain supplied. Returning no-auth\n");
ntlm_errno = NTLM_ERR_LOGON;
- return NULL;
+ return nullptr;
}
if (tmp.l > MAX_DOMAIN_LEN) {
debug("Domain string exceeds %d bytes, rejecting\n", MAX_DOMAIN_LEN);
ntlm_errno = NTLM_ERR_LOGON;
- return NULL;
+ return nullptr;
}
memcpy(domain, tmp.str, tmp.l);
user = domain + tmp.l;
if (tmp.str == NULL || tmp.l == 0) {
debug("No username supplied. Returning no-auth\n");
ntlm_errno = NTLM_ERR_LOGON;
- return NULL;
+ return nullptr;
}
if (tmp.l > MAX_USERNAME_LEN) {
debug("Username string exceeds %d bytes, rejecting\n", MAX_USERNAME_LEN);
ntlm_errno = NTLM_ERR_LOGON;
- return NULL;
+ return nullptr;
}
memcpy(user, tmp.str, tmp.l);
*(user + tmp.l) = '\0';
if (len != ENCODED_PASS_LEN || offset + len > auth_length || offset == 0) {
debug("LM response: insane data (pkt-sz: %d, fetch len: %d, offset: %d)\n", auth_length, len, offset);
ntlm_errno = NTLM_ERR_LOGON;
- return NULL;
+ return nullptr;
}
tmp.str = (char *)packet + offset;
tmp.l = len;
if (tmp.l > MAX_PASSWD_LEN) {
debug("Password string exceeds %d bytes, rejecting\n", MAX_PASSWD_LEN);
ntlm_errno = NTLM_ERR_LOGON;
- return NULL;
+ return nullptr;
}
/* Authenticating against the NT response doesn't seem to work... in SMB LM helper. */
fprintf(stderr,"Empty LM password supplied for user %s\\%s. "
"No-auth\n",domain,user);
ntlm_errno=NTLM_ERR_LOGON;
- return NULL;
+ return nullptr;
}
/* still fetch the NT response and check validity against empty password */
if (len != ENCODED_PASS_LEN || offset + len > auth_length || offset == 0) {
debug("NT response: insane data (pkt-sz: %d, fetch len: %d, offset: %d)\n", auth_length, len, offset);
ntlm_errno = NTLM_ERR_LOGON;
- return NULL;
+ return nullptr;
}
tmp.str = (char *)packet + offset;
tmp.l = len;
if (memcmp(tmp.str,lmencoded_empty_pass,ENCODED_PASS_LEN)==0) {
fprintf(stderr,"ERROR: Empty NT password supplied for user %s\\%s. No-auth\n", domain, user);
ntlm_errno = NTLM_ERR_LOGON;
- return NULL;
+ return nullptr;
}
}
}
if (rv != NTLM_ERR_NONE) { /* failed */
ntlm_errno = rv;
- return NULL;
+ return nullptr;
}
*(user - 1) = '\\'; /* hack. Performing, but ugly. */
* -l last-ditch-mode
* domain\controller ...
*/
-char *my_program_name = NULL;
+char *my_program_name = nullptr;
void
usage()
process_options(int argc, char *argv[])
{
int opt, j, had_error = 0;
- dc *new_dc = NULL, *last_dc = NULL;
+ dc *new_dc = nullptr, *last_dc = nullptr;
while (-1 != (opt = getopt(argc, argv, "bfld"))) {
switch (opt) {
case 'b':
obtain_challenge()
{
int j = 0;
- const char *ch = NULL;
+ const char *ch = nullptr;
for (j = 0; j < numcontrollers; ++j) {
debug("obtain_challenge: selecting %s\\%s (attempt #%d)\n",
current_dc->domain, current_dc->controller, j + 1);
current_dc = current_dc->next;
}
/* all DCs failed. */
- return NULL;
+ return nullptr;
}
void
ntlmhdr *fast_header;
char buf[NTLM_BLOB_BUFFER_SIZE];
char decoded[NTLM_BLOB_BUFFER_SIZE];
- char *ch2, *cred = NULL;
+ char *ch2, *cred = nullptr;
if (fgets(buf, NTLM_BLOB_BUFFER_SIZE, stdin) == NULL) {
fprintf(stderr, "fgets() failed! dying..... errno=%d (%s)\n", errno,
debug("options processed OK\n");
/* initialize FDescs */
- setbuf(stdout, NULL);
- setbuf(stderr, NULL);
+ setbuf(stdout, nullptr);
+ setbuf(stderr, nullptr);
/* select the first domain controller we're going to use */
current_dc = controllers;
WCHAR wszUserName[UNLEN+1]; // Unicode user name
WCHAR wszGroup[GNLEN+1]; // Unicode Group
- LPLOCALGROUP_USERS_INFO_0 pBuf = NULL;
+ LPLOCALGROUP_USERS_INFO_0 pBuf = nullptr;
LPLOCALGROUP_USERS_INFO_0 pTmpBuf;
DWORD dwLevel = 0;
DWORD dwFlags = LG_INCLUDE_INDIRECT;
* function should also return the names of the local
* groups in which the user is indirectly a member.
*/
- nStatus = NetUserGetLocalGroups(NULL,
+ nStatus = NetUserGetLocalGroups(nullptr,
wszUserName,
dwLevel,
dwFlags,
safe_free(target);
target = (char *)xmalloc(len);
if (target == NULL)
- return NULL;
+ return nullptr;
/* copy unicode buffer */
- WideCharToMultiByte(CP_ACP, 0, LsaStr.Buffer, LsaStr.Length, target, len, NULL, NULL );
+ WideCharToMultiByte(CP_ACP, 0, LsaStr.Buffer, LsaStr.Length, target, len, nullptr, nullptr);
/* add null termination */
target[len-1] = '\0';
PPOLICY_PRIMARY_DOMAIN_INFO ppdiDomainInfo;
PWKSTA_INFO_100 pwkiWorkstationInfo;
DWORD netret;
- char * DomainName = NULL;
+ char * DomainName = nullptr;
/*
* Always initialize the object attributes to all zeroes.
* The wki100_computername field contains a pointer to a UNICODE
* string containing the local computer name.
*/
- netret = NetWkstaGetInfo(NULL, 100, (LPBYTE *)&pwkiWorkstationInfo);
+ netret = NetWkstaGetInfo(nullptr, 100, (LPBYTE *)&pwkiWorkstationInfo);
if (netret == NERR_Success) {
/*
* We have the workstation name in:
* the LsaOpenPolicy function.
*/
status = LsaOpenPolicy(
- NULL,
+ nullptr,
&ObjectAttributes,
GENERIC_READ | POLICY_VIEW_LOCAL_INFORMATION,
&PolicyHandle
*/
debug("Member of Domain %s\n",DomainName);
} else {
- DomainName = NULL;
+ DomainName = nullptr;
}
}
}
-A can specify a Windows Local Group name allowed to authenticate.
-D can specify a Windows Local Group name not allowed to authenticate.
*/
-char *my_program_name = NULL;
+char *my_program_name = nullptr;
void
usage()
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
- NULL,
+ nullptr,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
(LPTSTR) &ErrorMessage,
0,
- NULL);
+ nullptr);
if (ErrorMessage[strlen(ErrorMessage) - 1] == '\n')
ErrorMessage[strlen(ErrorMessage) - 1] = '\0';
if (ErrorMessage[strlen(ErrorMessage) - 1] == '\r')
atexit(UnloadSecurityDll);
/* initialize FDescs */
- setbuf(stdout, NULL);
- setbuf(stderr, NULL);
+ setbuf(stdout, nullptr);
+ setbuf(stderr, nullptr);
while (manage_request()) {
/* everything is done within manage_request */
char* file = strwordtok(files, &saveptr);
while (file != NULL) {
error_count += parseOneConfigFile(file, depth);
- file = strwordtok(NULL, &saveptr);
+ file = strwordtok(nullptr, &saveptr);
}
#endif /* HAVE_GLOB */
return error_count;
}
}
- fout << " cfg_filename = NULL;" << std::endl <<
+ fout << " cfg_filename = nullptr;" << std::endl <<
"}" << std::endl << std::endl;
return rc;
}
fout << "#endif" << std::endl;
}
- fout << " cfg_filename = NULL;" << std::endl <<
+ fout << " cfg_filename = nullptr;" << std::endl <<
"}" << std::endl << std::endl;
}
fout << "#endif" << std::endl;
}
- fout << " cfg_filename = NULL;" << std::endl <<
+ fout << " cfg_filename = nullptr;" << std::endl <<
"}" << std::endl << std::endl;
}
fout << "parse_" << type << "(&" << loc << (array_flag ? "[0]" : "") << ");";
}
fout << std::endl;
- fout << " cfg_directive = NULL;" << std::endl;
+ fout << " cfg_directive = nullptr;" << std::endl;
if (ifdef.size()) {
fout <<
"#else" << std::endl <<
"\tchar\t*token;\n"
"\tif ((token = strtok(buff, w_space)) == NULL) \n"
"\t\treturn 1;\t/* ignore empty lines */\n"
- "\tConfigParser::SetCfgLine(strtok(NULL, \"\"));\n";
+ "\tConfigParser::SetCfgLine(strtok(nullptr, \"\"));\n";
for (const auto &e : head)
e.genParse(fout);
*
\code
mycontext = thisObject->data;
- thisObject->data = NULL;
+ thisObject->data = nullptr;
delete thisObject->head;
- mycontext = NULL;
+ mycontext = nullptr;
return;
\endcode
*
repContext->http->uri,
CachePeer,
repContext->http->request,
- inBuf, NULL);
+ inBuf, nullptr);
context->pullData();
} else {
// close or otherwise we may get stuck as nobody will notice the error?
debugs(33, 2, "Failed to generate TLS context for " << tlsConnectHostOrIp);
}
- // If generated ssl context = NULL, try to use static ssl context.
+ // If generated ssl context = nullptr, try to use static ssl context.
if (!ctx) {
if (!port->secure.staticContext) {
debugs(83, DBG_IMPORTANT, "Closing " << clientConnection->remote << " as lacking TLS context");
http->getConn() != nullptr && http->getConn()->getAuth() != nullptr ?
http->getConn()->getAuth() : http->request->auth_user_request);
#else
- NULL);
+ nullptr);
#endif
node = (clientStreamNode *)http->client_stream.tail->data;
clientStreamRead(node, http, node->readBuffer);
// "Select" state. It will not clear ours. XXX: It should always clear
// because a callback may have been active but was called before comm_close
// Update: we now do this in cleanFd()
- // Comm::SetSelect(temporaryFd_, COMM_SELECT_WRITE, NULL, NULL, 0);
+ // Comm::SetSelect(temporaryFd_, COMM_SELECT_WRITE, nullptr, nullptr, 0);
comm_close(temporaryFd_);
temporaryFd_ = -1;
DEBUG_DEVPOLL ? 0 : 8,
"Calling read handler on FD " << fd
);
- F->read_handler = NULL;
+ F->read_handler = nullptr;
hdl(fd, F->read_data);
++ statCounter.select_fds;
} else {
"no read handler for FD " << fd
);
// remove interest since no handler exist for this event.
- SetSelect(fd, COMM_SELECT_READ, NULL, NULL, 0);
+ SetSelect(fd, COMM_SELECT_READ, nullptr, nullptr, 0);
}
}
DEBUG_DEVPOLL ? 0 : 8,
"Calling write handler on FD " << fd
);
- F->write_handler = NULL;
+ F->write_handler = nullptr;
hdl(fd, F->write_data);
++ statCounter.select_fds;
} else {
"no write handler for FD " << fd
);
// remove interest since no handler exist for this event.
- SetSelect(fd, COMM_SELECT_WRITE, NULL, NULL, 0);
+ SetSelect(fd, COMM_SELECT_WRITE, nullptr, nullptr, 0);
}
}
}
if (kqoff == kqmax - 1) {
int ret;
- ret = kevent(kq, kqlst, kqmax, NULL, 0, &zero_timespec);
+ ret = kevent(kq, kqlst, kqmax, nullptr, 0, &zero_timespec);
/* jdc -- someone needs to do error checking... */
if (ret == -1) {
for (i = 0; i < num; ++i) {
int fd = (int) ke[i].ident;
- PF *hdl = NULL;
+ PF *hdl = nullptr;
fde *F = &fd_table[fd];
if (ke[i].flags & EV_ERROR) {
if (ke[i].filter == EVFILT_READ || F->flags.read_pending) {
if ((hdl = F->read_handler) != NULL) {
- F->read_handler = NULL;
+ F->read_handler = nullptr;
hdl(fd, F->read_data);
}
}
if (ke[i].filter == EVFILT_WRITE) {
if ((hdl = F->write_handler) != NULL) {
- F->write_handler = NULL;
+ F->write_handler = nullptr;
hdl(fd, F->write_data);
}
}
int i;
int fd;
int maxfd = 0;
- PF *hdl = NULL;
+ PF *hdl = nullptr;
fd_set read_mask;
fd_set write_mask;
FD_ZERO(&read_mask);
++ statCounter.syscalls.selects;
- if (select(maxfd, &read_mask, &write_mask, NULL, &zero_tv) < 1)
+ if (select(maxfd, &read_mask, &write_mask, nullptr, &zero_tv) < 1)
return incoming_sockets_accepted;
for (i = 0; i < nfds; ++i) {
if (FD_ISSET(fd, &read_mask)) {
if ((hdl = fd_table[fd].read_handler) != NULL) {
- fd_table[fd].read_handler = NULL;
- commUpdateReadBits(fd, NULL);
+ fd_table[fd].read_handler = nullptr;
+ commUpdateReadBits(fd, nullptr);
hdl(fd, fd_table[fd].read_data);
} else {
debugs(5, DBG_IMPORTANT, "comm_select_incoming: FD " << fd << " NULL read handler");
if (FD_ISSET(fd, &write_mask)) {
if ((hdl = fd_table[fd].write_handler) != NULL) {
- fd_table[fd].write_handler = NULL;
- commUpdateWriteBits(fd, NULL);
+ fd_table[fd].write_handler = nullptr;
+ commUpdateWriteBits(fd, nullptr);
hdl(fd, fd_table[fd].write_data);
} else {
debugs(5, DBG_IMPORTANT, "comm_select_incoming: FD " << fd << " NULL write handler");
fd_set pendingfds;
fd_set writefds;
- PF *hdl = NULL;
+ PF *hdl = nullptr;
int fd;
int maxfd;
int num;
debugs(5, 6, "comm_select: FD " << fd << " ready for reading");
if ((hdl = F->read_handler)) {
- F->read_handler = NULL;
- commUpdateReadBits(fd, NULL);
+ F->read_handler = nullptr;
+ commUpdateReadBits(fd, nullptr);
hdl(fd, F->read_data);
++ statCounter.select_fds;
F = &fd_table[fd];
if ((hdl = F->write_handler)) {
- F->write_handler = NULL;
- commUpdateWriteBits(fd, NULL);
+ F->write_handler = nullptr;
+ commUpdateWriteBits(fd, nullptr);
hdl(fd, F->write_data);
++ statCounter.select_fds;
}
debugs(5, 6, "comm_select: FD " << fd << " ready for writing");
if ((hdl = F->write_handler)) {
- F->write_handler = NULL;
- commUpdateWriteBits(fd, NULL);
+ F->write_handler = nullptr;
+ commUpdateWriteBits(fd, nullptr);
hdl(fd, F->write_data);
++ statCounter.select_fds;
fd_set write_x;
struct timeval tv;
- AsyncCall::Pointer ch = NULL;
- fde *F = NULL;
+ AsyncCall::Pointer ch = nullptr;
+ fde *F = nullptr;
struct stat sb;
debugs(5, DBG_CRITICAL, "examine_select: Examining open file descriptors...");
ScheduleCallHere(F->timeoutHandler);
}
- F->closeHandler = NULL;
- F->timeoutHandler = NULL;
- F->read_handler = NULL;
- F->write_handler = NULL;
+ F->closeHandler = nullptr;
+ F->timeoutHandler = nullptr;
+ F->read_handler = nullptr;
+ F->write_handler = nullptr;
FD_CLR(fd, readfds);
FD_CLR(fd, writefds);
}
if (!dbg_mutex) {
HMODULE krnl_lib = GetModuleHandle("Kernel32");
- PFInitializeCriticalSectionAndSpinCount InitializeCriticalSectionAndSpinCount = NULL;
+ PFInitializeCriticalSectionAndSpinCount InitializeCriticalSectionAndSpinCount = nullptr;
if (krnl_lib)
InitializeCriticalSectionAndSpinCount =
DWORD Type = 0;
DWORD Size = 0;
LONG Result;
- Result = RegQueryValueEx(hndKey, "Domain", NULL, &Type, NULL, &Size);
+ Result = RegQueryValueEx(hndKey, "Domain", nullptr, &Type, nullptr, &Size);
if (Result == ERROR_SUCCESS && Size) {
t = (char *) xmalloc(Size);
- RegQueryValueEx(hndKey, "Domain", NULL, &Type, (LPBYTE) t, &Size);
+ RegQueryValueEx(hndKey, "Domain", nullptr, &Type, (LPBYTE) t, &Size);
debugs(78, DBG_IMPORTANT, "Adding domain " << t << " from Registry");
idnsAddPathComponent(t);
xfree(t);
}
- Result = RegQueryValueEx(hndKey, "SearchList", NULL, &Type, NULL, &Size);
+ Result = RegQueryValueEx(hndKey, "SearchList", nullptr, &Type, nullptr, &Size);
if (Result == ERROR_SUCCESS && Size) {
t = (char *) xmalloc(Size);
- RegQueryValueEx(hndKey, "SearchList", NULL, &Type, (LPBYTE) t, &Size);
+ RegQueryValueEx(hndKey, "SearchList", nullptr, &Type, (LPBYTE) t, &Size);
token = strtok(t, Separator);
while (token) {
idnsAddPathComponent(token);
debugs(78, DBG_IMPORTANT, "Adding domain " << token << " from Registry");
- token = strtok(NULL, Separator);
+ token = strtok(nullptr, Separator);
}
xfree(t);
}
DWORD Type = 0;
DWORD Size = 0;
LONG Result;
- Result = RegQueryValueEx(hndKey, "DhcpNameServer", NULL, &Type, NULL, &Size);
+ Result = RegQueryValueEx(hndKey, "DhcpNameServer", nullptr, &Type, nullptr, &Size);
if (Result == ERROR_SUCCESS && Size) {
t = (char *) xmalloc(Size);
- RegQueryValueEx(hndKey, "DhcpNameServer", NULL, &Type, (LPBYTE) t, &Size);
+ RegQueryValueEx(hndKey, "DhcpNameServer", nullptr, &Type, (LPBYTE) t, &Size);
token = strtok(t, ", ");
while (token) {
idnsAddNameserver(token);
result = true;
debugs(78, DBG_IMPORTANT, "Adding DHCP nameserver " << token << " from Registry");
- token = strtok(NULL, ",");
+ token = strtok(nullptr, ",");
}
xfree(t);
}
- Result = RegQueryValueEx(hndKey, "NameServer", NULL, &Type, NULL, &Size);
+ Result = RegQueryValueEx(hndKey, "NameServer", nullptr, &Type, nullptr, &Size);
if (Result == ERROR_SUCCESS && Size) {
t = (char *) xmalloc(Size);
- RegQueryValueEx(hndKey, "NameServer", NULL, &Type, (LPBYTE) t, &Size);
+ RegQueryValueEx(hndKey, "NameServer", nullptr, &Type, (LPBYTE) t, &Size);
token = strtok(t, ", ");
while (token) {
debugs(78, DBG_IMPORTANT, "Adding nameserver " << token << " from Registry");
idnsAddNameserver(token);
result = true;
- token = strtok(NULL, ", ");
+ token = strtok(nullptr, ", ");
}
xfree(t);
}
char *keyname;
FILETIME ftLastWriteTime;
- if (RegQueryInfoKey(hndKey, NULL, NULL, NULL, &InterfacesCount, &MaxSubkeyLen, NULL, NULL, NULL, NULL, NULL, NULL) == ERROR_SUCCESS) {
+ if (RegQueryInfoKey(hndKey, nullptr, nullptr, nullptr, &InterfacesCount, &MaxSubkeyLen, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr) == ERROR_SUCCESS) {
keyname = (char *) xmalloc(++MaxSubkeyLen);
for (i = 0; i < (int) InterfacesCount; ++i) {
DWORD j;
j = MaxSubkeyLen;
- if (RegEnumKeyEx(hndKey, i, keyname, &j, NULL, NULL, NULL, &ftLastWriteTime) == ERROR_SUCCESS) {
+ if (RegEnumKeyEx(hndKey, i, keyname, &j, nullptr, nullptr, nullptr, &ftLastWriteTime) == ERROR_SUCCESS) {
char *newkeyname;
newkeyname = (char *) xmalloc(sizeof(REG_TCPIP_PARA_INTERFACES) + j + 2);
strcpy(newkeyname, REG_TCPIP_PARA_INTERFACES);
DWORD Type = 0;
DWORD Size = 0;
LONG Result;
- Result = RegQueryValueEx(hndKey2, "DhcpNameServer", NULL, &Type, NULL, &Size);
+ Result = RegQueryValueEx(hndKey2, "DhcpNameServer", nullptr, &Type, nullptr, &Size);
if (Result == ERROR_SUCCESS && Size) {
t = (char *) xmalloc(Size);
- RegQueryValueEx(hndKey2, "DhcpNameServer", NULL, &Type, (LPBYTE)t, &Size);
+ RegQueryValueEx(hndKey2, "DhcpNameServer", nullptr, &Type, (LPBYTE)t, &Size);
token = strtok(t, ", ");
while (token) {
debugs(78, DBG_IMPORTANT, "Adding DHCP nameserver " << token << " from Registry");
idnsAddNameserver(token);
result = true;
- token = strtok(NULL, ", ");
+ token = strtok(nullptr, ", ");
}
xfree(t);
}
- Result = RegQueryValueEx(hndKey2, "NameServer", NULL, &Type, NULL, &Size);
+ Result = RegQueryValueEx(hndKey2, "NameServer", nullptr, &Type, nullptr, &Size);
if (Result == ERROR_SUCCESS && Size) {
t = (char *) xmalloc(Size);
- RegQueryValueEx(hndKey2, "NameServer", NULL, &Type, (LPBYTE)t, &Size);
+ RegQueryValueEx(hndKey2, "NameServer", nullptr, &Type, (LPBYTE)t, &Size);
token = strtok(t, ", ");
while (token) {
debugs(78, DBG_IMPORTANT, "Adding nameserver " << token << " from Registry");
idnsAddNameserver(token);
result = true;
- token = strtok(NULL, ", ");
+ token = strtok(nullptr, ", ");
}
xfree(t);
DWORD Type = 0;
DWORD Size = 0;
LONG Result;
- Result = RegQueryValueEx(hndKey, "NameServer", NULL, &Type, NULL, &Size);
+ Result = RegQueryValueEx(hndKey, "NameServer", nullptr, &Type, nullptr, &Size);
if (Result == ERROR_SUCCESS && Size) {
t = (char *) xmalloc(Size);
- RegQueryValueEx(hndKey, "NameServer", NULL, &Type, (LPBYTE) t, &Size);
+ RegQueryValueEx(hndKey, "NameServer", nullptr, &Type, (LPBYTE) t, &Size);
token = strtok(t, ", ");
while (token) {
debugs(78, DBG_IMPORTANT, "Adding nameserver " << token << " from Registry");
idnsAddNameserver(token);
result = true;
- token = strtok(NULL, ", ");
+ token = strtok(nullptr, ", ");
}
xfree(t);
}
mib[5] = RTF_LLINFO;
#endif
- if (sysctl(mib, 6, NULL, &needed, NULL, 0) < 0) {
+ if (sysctl(mib, 6, nullptr, &needed, nullptr, 0) < 0) {
debugs(28, DBG_CRITICAL, "ERROR: Cannot estimate ARP table size!");
clear();
return false;
return false;
}
- if (sysctl(mib, 6, buf, &needed, NULL, 0) < 0) {
+ if (sysctl(mib, 6, buf, &needed, nullptr, 0) < 0) {
debugs(28, DBG_CRITICAL, "ERROR: Cannot retrieve ARP table!");
xfree(buf);
clear();
DWORD ipNetTableLen = 0;
- PMIB_IPNETTABLE NetTable = NULL;
+ PMIB_IPNETTABLE NetTable = nullptr;
DWORD i;
* open files, so we won't allow delayed close.
*/
while (!diskWriteIsComplete(fd))
- diskHandleWrite(fd, NULL);
+ diskHandleWrite(fd, nullptr);
#else
F->flags.close_request = true;
debugs(6, 2, "file_close: FD " << fd << ", delaying close");
int tlu = 0;
/* make standard output line buffered */
- if (setvbuf(stdout, NULL, _IOLBF, 0) != 0)
+ if (setvbuf(stdout, nullptr, _IOLBF, 0) != 0)
exit(EXIT_FAILURE);
/* speed up the access() calls below */
{
int n;
struct addrinfo *from = nullptr;
-// struct ip6_hdr *ip = NULL;
+// struct ip6_hdr *ip = nullptr;
static char *pkt = nullptr;
struct icmp6_hdr *icmp6header = nullptr;
icmpEchoData *echo = nullptr;
memFree(buf, MEM_4K_BUF);
#else
- reply->setHeaders(Http::scBadRequest, "Bad Request", NULL, -1, squid_curtime, -2);
+ reply->setHeaders(Http::scBadRequest, "Bad Request", nullptr, -1, squid_curtime, -2);
s->replaceHttpReply(reply);
storeAppendPrintf(s, "NETDB support not compiled into this Squid cache.\n");
#endif
{
if (doUnlink) {
delete [] static_cast<char *>(theMem);
- theMem = NULL;
+ theMem = nullptr;
Segments.erase(theName);
debugs(54, 3, "unlinked " << theName << " fake segment");
}
pid_t pid;
Ip::Address tmp_addr;
- struct addrinfo *aiCS = NULL;
- struct addrinfo *aiPS = NULL;
+ struct addrinfo *aiCS = nullptr;
+ struct addrinfo *aiPS = nullptr;
int crfd = -1;
int prfd = -1;
*wfd = -1;
if (hIpc)
- *hIpc = NULL;
+ *hIpc = nullptr;
if (WIN32_OS_version != _WIN_OS_WINNT) {
getsockopt(INVALID_SOCKET, SOL_SOCKET, SO_OPENTYPE, (char *) &opt, &optlen);
params.args = (char **) args;
- thread = _beginthreadex(NULL, 0, ipc_thread_1, ¶ms, 0, NULL);
+ thread = _beginthreadex(nullptr, 0, ipc_thread_1, ¶ms, 0, nullptr);
if (thread == 0) {
int xerrno = errno;
int t1, t2, t3, retval = -1;
int p2c[2] = {-1, -1};
int c2p[2] = {-1, -1};
- HANDLE hProcess = NULL, thread = NULL;
+ HANDLE hProcess = nullptr, thread = nullptr;
pid_t pid = -1;
struct thread_params thread_params;
PROCESS_INFORMATION pi;
long F;
int prfd_ipc = -1, pwfd_ipc = -1, crfd_ipc = -1, cwfd_ipc = -1;
- char *prog = NULL, *buf1 = NULL;
+ char *prog = nullptr, *buf1 = nullptr;
Ip::Address PS_ipc;
Ip::Address CS_ipc;
- struct addrinfo *aiPS_ipc = NULL;
- struct addrinfo *aiCS_ipc = NULL;
+ struct addrinfo *aiPS_ipc = nullptr;
+ struct addrinfo *aiCS_ipc = nullptr;
struct ipc_params *params = (struct ipc_params *) in_params;
int type = params->type;
if (type == IPC_TCP_SOCKET) {
debugs(54, 3, "ipcCreate: calling accept on FD " << crfd);
- if ((fd = accept(crfd, NULL, NULL)) < 0) {
+ if ((fd = accept(crfd, nullptr, nullptr)) < 0) {
int xerrno = errno;
debugs(54, DBG_CRITICAL, "ipcCreate: FD " << crfd << " accept: " << xstrerr(xerrno));
goto cleanup;
do {
strcat(buf1, str);
strcat(buf1, " ");
- } while ((str = strtok(NULL, w_space)));
+ } while ((str = strtok(nullptr, w_space)));
x = 1;
strcat(buf1, " ");
}
- if (CreateProcess(buf1 + 4096, buf1, NULL, NULL, TRUE, CREATE_NO_WINDOW,
- NULL, NULL, &si, &pi)) {
+ if (CreateProcess(buf1 + 4096, buf1, nullptr, nullptr, TRUE, CREATE_NO_WINDOW,
+ nullptr, nullptr, &si, &pi)) {
pid = pi.dwProcessId;
hProcess = pi.hProcess;
} else {
else
thread_params.rfd = prfd_ipc;
- thread = (HANDLE)_beginthreadex(NULL, 0, ipc_thread_2, &thread_params, 0, NULL);
+ thread = (HANDLE)_beginthreadex(nullptr, 0, ipc_thread_2, &thread_params, 0, nullptr);
if (!thread) {
int xerrno = errno;
#ifdef TIOCNOTTY
if ((i = open("/dev/tty", O_RDWR | O_TEXT)) >= 0) {
- ioctl(i, TIOCNOTTY, NULL);
+ ioctl(i, TIOCNOTTY, nullptr);
close(i);
}
#define PCONN_FDS_SZ 8 /* pconn set size, increase for better memcache hit rate */
-//TODO: re-attach to MemPools. WAS: static Mem::Allocator *pconn_fds_pool = NULL;
+//TODO: re-attach to MemPools. WAS: static Mem::Allocator *pconn_fds_pool = nullptr;
PconnModule * PconnModule::instance = nullptr;
CBDATA_CLASS_INIT(IdleConnList);
/* preserve request -- we need its size to update counters */
/* requestUnlink(r); */
- /* fetch->entry->mem_obj->request = NULL; */
+ /* fetch->entry->mem_obj->request = nullptr; */
if (!fetch->pd->cd) {
peerDigestFetchAbort(fetch, buf, "304 without the old in-memory digest");
#if USE_IBM_KERBEROS
#include <ibm_svc/krb5_svc.h>
const char *KRB5_CALLCONV error_message(long code) {
- char *msg = NULL;
+ char *msg = nullptr;
krb5_svc_get_msg(code, &msg);
return msg;
}
code =
krb5_make_principal(kparam.context, &creds2.server,
(krb5_const_realm)&client_realm, KRB5_TGS_NAME,
- (krb5_const_realm)&client_realm, NULL);
+ (krb5_const_realm)&client_realm, nullptr);
if (code) {
debugs(11, 5,
"Error while getting krbtgt principal : " <<
return (1);
}
code =
- krb5_get_kdc_cred(kparam.context, kparam.cc, flags, NULL,
- NULL, &creds2, &creds);
+ krb5_get_kdc_cred(kparam.context, kparam.cc, flags, nullptr,
+ nullptr, &creds2, &creds);
krb5_free_creds(kparam.context, &creds2);
#endif
if (code) {
krb5_get_init_creds_opt_set_renew_life(&options, rlife);
code =
krb5_get_init_creds_keytab(kparam.context, creds, principal,
- keytab, 0, NULL, &options);
+ keytab, 0, nullptr, &options);
#endif
if (code) {
debugs(11, 5,
http->getConn() != nullptr && http->getConn()->getAuth() != nullptr ?
http->getConn()->getAuth() : http->request->auth_user_request);
#else
- NULL);
+ nullptr);
#endif
node = (clientStreamNode *)http->client_stream.tail->data;
{
#if _SQUID_WINDOWS_
- hFile = CreateFile(TEXT(filename.c_str()), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
+ hFile = CreateFile(TEXT(filename.c_str()), GENERIC_READ, 0, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr);
if (hFile == INVALID_HANDLE_VALUE)
#else
fd = open(filename.c_str(), O_RDWR);
squid_bio_write,
squid_bio_read,
squid_bio_puts,
- NULL, // squid_bio_gets not supported
+ nullptr, // squid_bio_gets not supported
squid_bio_ctrl,
squid_bio_create,
squid_bio_destroy,
default:
debugs(83, DBG_IMPORTANT, "ERROR: ssl_temp_rsa_cb: Unexpected key length " << keylen);
- return NULL;
+ return nullptr;
}
if (rsa == NULL) {
debugs(83, DBG_IMPORTANT, "ERROR: ssl_temp_rsa_cb: Failed to generate key " << keylen);
- return NULL;
+ return nullptr;
}
if (newkey) {
if (Debug::Enabled(83, 5))
- PEM_write_RSAPrivateKey(debug_log, rsa, NULL, NULL, 0, NULL, NULL);
+ PEM_write_RSAPrivateKey(debug_log, rsa, nullptr, nullptr, 0, nullptr, nullptr);
debugs(83, DBG_IMPORTANT, "Generated ephemeral RSA key of length " << keylen);
}
X509 ***pCert = (X509 ***)ctx->cert;
X509 * cert = pCert && *pCert ? **pCert : NULL;
#elif SQUID_SSLGETCERTIFICATE_BUGGY
- X509 * cert = NULL;
+ X509 * cert = nullptr;
assert(0);
#else
// Temporary ssl for getting X509 certificate from SSL_CTX.
storeClientListSearch(const MemObject * mem, void *data)
{
dlink_node *node;
- store_client *sc = NULL;
+ store_client *sc = nullptr;
for (node = mem->clients.head; node; node = node->next) {
sc = node->data;
return sc;
}
- return NULL;
+ return nullptr;
}
int
sd_state = StoreDigestState();
#else
- store_digest = NULL;
+ store_digest = nullptr;
debugs(71, 3, "Local cache digest is 'off'");
#endif
}
if (!fi->file) {
fprintf(stderr, "cannot open %s: %s\n", fname, strerror(errno));
- return NULL;
+ return nullptr;
} else
fprintf(stderr, "opened %s\n", fname);
static void
cacheDestroy(Cache * cache)
{
- CacheEntry *e = NULL;
+ CacheEntry *e = nullptr;
hash_table *hash;
assert(cache);
hash = cache->hash;
static void
cacheResetDigest(Cache * cache)
{
- CacheEntry *e = NULL;
+ CacheEntry *e = nullptr;
hash_table *hash;
struct timeval t_start, t_end;
if (!cache->count)
return;
- gettimeofday(&t_start, NULL);
+ gettimeofday(&t_start, nullptr);
hash_first(hash);
cache->digest->add(e->key);
}
- gettimeofday(&t_end, NULL);
+ gettimeofday(&t_end, nullptr);
assert(cache->digest->count == cache->count);
fprintf(stderr, "%s: init-ed digest with %d entries\n",
cache->name, cache->digest->count);
tvSubDsec(t_start, t_end),
(double) 1e6 * tvSubDsec(t_start, t_end) / cache->count);
/* check how long it takes to traverse the hash */
- gettimeofday(&t_start, NULL);
+ gettimeofday(&t_start, nullptr);
hash_first(hash);
for (e = (CacheEntry *)hash_next(hash); e; e = (CacheEntry *)hash_next(hash)) {}
- gettimeofday(&t_end, NULL);
+ gettimeofday(&t_end, nullptr);
fprintf(stderr, "%s: hash scan took: %f sec, %f sec/M\n",
cache->name,
tvSubDsec(t_start, t_end),
char *url;
char *method;
HttpRequestMethod method_id = METHOD_NONE;
- char *hier = NULL;
+ char *hier = nullptr;
assert(fi);
int
main(int argc, char *argv[])
{
- FileIterator **fis = NULL;
+ FileIterator **fis = nullptr;
const int fi_count = argc - 1;
int active_fi_count = 0;
time_t ready_time;
#define STUB_API "wordlist.cc"
#include "tests/STUB.h"
-const char *wordlistAdd(wordlist **, const char *) STUB_RETVAL(NULL)
+const char *wordlistAdd(wordlist **, const char *) STUB_RETVAL(nullptr)
void wordlistDestroy(wordlist **) STUB
return proxy_auths[count][1];
}
- return NULL;
+ return nullptr;
}
static
Auth::Scheme::Pointer theScheme = Auth::Scheme::Find(type_str);
if (theScheme == NULL) {
- return NULL;
+ return nullptr;
//fatalf("Unknown authentication scheme '%s'.\n", type_str);
}
for (unsigned position=0; position < param_count; ++position) {
char *param_str=xstrdup(params[position]);
strtok(param_str, w_space);
- ConfigParser::SetCfgLine(strtok(NULL, ""));
+ ConfigParser::SetCfgLine(strtok(nullptr, ""));
scheme->parse(scheme, config.size(), param_str);
}
}
char *filename;
// XXX tempnam is obsolete since POSIX.2008-1
// tmpfile is not an option, we want the created files to stick around
- if ((filename = tempnam(NULL, APP_SHORTNAME)) == NULL ||
+ if ((filename = tempnam(nullptr, APP_SHORTNAME)) == NULL ||
(fp = fopen(filename, "w")) == NULL) {
umask(prev_umask);
return;
FD_SET(unlinkd_rfd, &R);
to.tv_sec = 0;
to.tv_usec = 100000;
- select(unlinkd_rfd + 1, &R, NULL, NULL, &to);
+ select(unlinkd_rfd + 1, &R, nullptr, nullptr, &to);
#endif
}
SQUIDCEXTERN LPCRITICAL_SECTION dbg_mutex;
void WIN32_ExceptionHandlerCleanup(void);
-static LPTOP_LEVEL_EXCEPTION_FILTER Win32_Old_ExceptionHandler = NULL;
+static LPTOP_LEVEL_EXCEPTION_FILTER Win32_Old_ExceptionHandler = nullptr;
int
Win32__WSAFDIsSet(int fd, fd_set FAR * set)
#if _SQUID_WINDOWS_
int reply;
- char *tmpfile = tempnam(NULL, "tmp0000");
+ char *tmpfile = tempnam(nullptr, "tmp0000");
FILE *fp = fopen(tmpfile, "w+");
#else
static bool
loadTlsParameters()
{
- const char *err = NULL;
+ const char *err = nullptr;
int x;
if ((x = gnutls_priority_set_direct(Transport::Config.session, Transport::Config.params, &err)) != GNUTLS_E_SUCCESS) {
if (x == GNUTLS_E_INVALID_REQUEST)
/* Bug 3854: AIX 6.1 tries to link in this fde.h global symbol
* despite squidclient not using any of the fd_* code.
*/
-fde *fde::Table = NULL;
+fde *fde::Table = nullptr;
#endif
#if _SQUID_WINDOWS_