]> git.ipfire.org Git - thirdparty/squid.git/blobdiff - src/peer_proxy_negotiate_auth.cc
Maintenance: Removed most NULLs using modernize-use-nullptr (#1075)
[thirdparty/squid.git] / src / peer_proxy_negotiate_auth.cc
index 77dc87a79fa507d050f44cf4b3f13e520a55d3a8..00f3260cb0b75a22014a5a84cc89b0401311c632 100644 (file)
@@ -103,7 +103,7 @@ static struct kstruct {
     krb5_context context;
     krb5_ccache cc;
 } kparam = {
-    NULL, NULL
+    nullptr, nullptr
 };
 
 /*
@@ -185,9 +185,9 @@ void krb5_cleanup() {
     if (kparam.context) {
         if (kparam.cc)
             krb5_cc_destroy(kparam.context, kparam.cc);
-        kparam.cc = NULL;
+        kparam.cc = nullptr;
         krb5_free_context(kparam.context);
-        kparam.context = NULL;
+        kparam.context = nullptr;
     }
 }
 
@@ -197,15 +197,15 @@ int krb5_create_cache(char *kf, char *pn) {
 #define MAX_RENEW_TIME "365d"
 #define DEFAULT_SKEW (krb5_deltat) 600
 
-    static char *keytab_filename = NULL, *principal_name = NULL;
-    static krb5_keytab keytab = 0;
+    static char *keytab_filename = nullptr, *principal_name = nullptr;
+    static krb5_keytab keytab = nullptr;
     static krb5_keytab_entry entry;
     static krb5_kt_cursor cursor;
-    static krb5_creds *creds = NULL;
+    static krb5_creds *creds = nullptr;
 #if USE_HEIMDAL_KRB5 && !HAVE_KRB5_GET_RENEWED_CREDS
     static krb5_creds creds2;
 #endif
-    static krb5_principal principal = NULL;
+    static krb5_principal principal = nullptr;
     static krb5_deltat skew;
 
 #if HAVE_KRB5_GET_INIT_CREDS_OPT_ALLOC
@@ -233,14 +233,14 @@ restart:
      * Check if credentials need to be renewed
      */
     if (creds &&
-            (creds->times.endtime - time(0) > skew) &&
-            (creds->times.renew_till - time(0) > 2 * skew)) {
-        if (creds->times.endtime - time(0) < 2 * skew) {
+            (creds->times.endtime - time(nullptr) > skew) &&
+            (creds->times.renew_till - time(nullptr) > 2 * skew)) {
+        if (creds->times.endtime - time(nullptr) < 2 * skew) {
 #if HAVE_KRB5_GET_RENEWED_CREDS
             /* renew ticket */
             code =
                 krb5_get_renewed_creds(kparam.context, creds, principal,
-                                       kparam.cc, NULL);
+                                       kparam.cc, nullptr);
 #else
             /* renew ticket */
             flags.i = 0;
@@ -279,7 +279,7 @@ restart:
             if (code) {
                 if (code == KRB5KRB_AP_ERR_TKT_EXPIRED) {
                     krb5_free_creds(kparam.context, creds);
-                    creds = NULL;
+                    creds = nullptr;
                     /* this can happen because of clock skew */
                     goto restart;
                 }
@@ -311,7 +311,7 @@ restart:
             return (1);
         }
         code =
-            profile_get_integer(profile, "libdefaults", "clockskew", 0,
+            profile_get_integer(profile, "libdefaults", "clockskew", nullptr,
                                 5 * 60, &skew);
         if (profile)
             profile_release(profile);
@@ -421,7 +421,7 @@ restart:
         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);
 #if HAVE_KRB5_GET_INIT_CREDS_FREE_CONTEXT
         krb5_get_init_creds_opt_free(kparam.context, options);
 #else
@@ -507,14 +507,14 @@ char *peer_proxy_negotiate_auth(char *principal_name, char *proxy, int flags) {
     gss_buffer_desc service = GSS_C_EMPTY_BUFFER;
     gss_buffer_desc input_token = GSS_C_EMPTY_BUFFER;
     gss_buffer_desc output_token = GSS_C_EMPTY_BUFFER;
-    char *token = NULL;
+    char *token = nullptr;
 
-    setbuf(stdout, NULL);
-    setbuf(stdin, NULL);
+    setbuf(stdout, nullptr);
+    setbuf(stdin, nullptr);
 
     if (!proxy) {
         debugs(11, 5, "Error : No proxy server name");
-        return NULL;
+        return nullptr;
     }
 
     if (!(flags & PEER_PROXY_NEGOTIATE_NOKEYTAB)) {
@@ -523,11 +523,11 @@ char *peer_proxy_negotiate_auth(char *principal_name, char *proxy, int flags) {
                    "Creating credential cache for " << principal_name);
         else
             debugs(11, 5, "Creating credential cache");
-        rc = krb5_create_cache(NULL, principal_name);
+        rc = krb5_create_cache(nullptr, principal_name);
         if (rc) {
             debugs(11, 5, "Error : Failed to create Kerberos cache");
             krb5_cleanup();
-            return NULL;
+            return nullptr;
         }
     }
 
@@ -552,7 +552,7 @@ char *peer_proxy_negotiate_auth(char *principal_name, char *proxy, int flags) {
                                         0,
                                         0,
                                         GSS_C_NO_CHANNEL_BINDINGS,
-                                        &input_token, NULL, &output_token, NULL, NULL);
+                                        &input_token, nullptr, &output_token, nullptr, nullptr);
 
     if (check_gss_err(major_status, minor_status, "gss_init_sec_context()"))
         goto cleanup;
@@ -570,7 +570,7 @@ char *peer_proxy_negotiate_auth(char *principal_name, char *proxy, int flags) {
     }
 
 cleanup:
-    gss_delete_sec_context(&minor_status, &gss_context, NULL);
+    gss_delete_sec_context(&minor_status, &gss_context, nullptr);
     gss_release_buffer(&minor_status, &service);
     gss_release_buffer(&minor_status, &input_token);
     gss_release_buffer(&minor_status, &output_token);