]> eyrie.org Git - kerberos/pam-krb5.git/commitdiff
Fix cppcheck errors with pkinit_auth
authorRuss Allbery <rra@debian.org>
Sun, 29 Mar 2020 04:39:52 +0000 (21:39 -0700)
committerRuss Allbery <rra@debian.org>
Sun, 29 Mar 2020 04:52:52 +0000 (21:52 -0700)
Restructure the code so that there is only one preprocessor
conditional block, avoiding various cppcheck warnings.

module/alt-auth.c
module/auth.c
tests/data/cppcheck.supp

index fc490491bbd60fcd2a5d8560ef7f94f9b017f5fc..f45b6578bed9132b6887705e853416e000842611 100644 (file)
@@ -36,7 +36,8 @@
  * on any error.
  */
 int
-pamk5_map_principal(struct pam_args *args, const char *username, char **principal)
+pamk5_map_principal(struct pam_args *args, const char *username,
+                    char **principal)
 {
     char *user = NULL;
     char *realm;
index 01d1271209069664a5f248e3f69a31dd2ea5ba8e..065ce97b6596de19c7f41f17ee06bbc88714b945 100644 (file)
@@ -566,27 +566,23 @@ pkinit_auth(struct pam_args *args, const char *service, krb5_creds **creds)
     if (retval != 0)
         return retval;
     set_credential_options(args, opts, service != NULL);
+
+    /* Finally, do the actual work and return the results. */
 #    ifdef HAVE_KRB5_HEIMDAL
     retval = krb5_get_init_creds_opt_set_pkinit(
         ctx->context, opts, ctx->princ, args->config->pkinit_user,
         args->config->pkinit_anchors, NULL, NULL, 0, pamk5_prompter_krb5, args,
         NULL);
-#    endif
-    if (retval != 0)
-        goto done;
-
-        /* Finally, do the actual work and return the results. */
-#    ifdef HAVE_KRB5_HEIMDAL
-    retval =
-        krb5_get_init_creds_password(ctx->context, *creds, ctx->princ, NULL,
-                                     NULL, args, 0, (char *) service, opts);
-#    else /* !HAVE_KRB5_HEIMDAL */
+    if (retval == 0)
+        retval = krb5_get_init_creds_password(ctx->context, *creds, ctx->princ,
+                                              NULL, NULL, args, 0,
+                                              (char *) service, opts);
+#    else  /* !HAVE_KRB5_HEIMDAL */
     retval = krb5_get_init_creds_password(
         ctx->context, *creds, ctx->princ, NULL,
         pamk5_prompter_krb5_no_password, args, 0, (char *) service, opts);
-#    endif
+#    endif /* !HAVE_KRB5_HEIMDAL */
 
-done:
     krb5_get_init_creds_opt_free(ctx->context, opts);
     if (retval != 0) {
         krb5_free_cred_contents(ctx->context, *creds);
index 42bcdc538914925d5bfe95829927701972f11f89..442c431daba7e8b5dcebddb96ef40f2249de2963 100644 (file)
@@ -52,4 +52,4 @@ uninitvar:php/php5_remctl.c:129
 uninitvar:php/php5_remctl.c:321
 
 // (pam-krb5) cppcheck doesn't recognize the unused attribute on labels.
-unusedLabel:module/auth.c:898
+unusedLabel:module/auth.c:895