]> git.ipfire.org Git - thirdparty/openssh-portable.git/commitdiff
pthread_create(3) returns positive values on failure.
authorElliott Hughes <enh@google.com>
Thu, 25 Apr 2019 20:36:27 +0000 (13:36 -0700)
committerDarren Tucker <dtucker@dtucker.net>
Fri, 7 Jun 2019 04:16:21 +0000 (14:16 +1000)
Found by inspection after finding similar bugs in other code used by
Android.

auth-pam.c

index 289d9f4f727de12b97767dbb8fa4515d1e9c529e..8efd7b67297e403151d1e3cf2c8be429da7d0fe6 100644 (file)
@@ -777,6 +777,7 @@ sshpam_init_ctx(Authctxt *authctxt)
 {
        struct pam_ctxt *ctxt;
        int socks[2];
+       int result;
 
        debug3("PAM: %s entering", __func__);
        /*
@@ -803,9 +804,10 @@ sshpam_init_ctx(Authctxt *authctxt)
        }
        ctxt->pam_psock = socks[0];
        ctxt->pam_csock = socks[1];
-       if (pthread_create(&ctxt->pam_thread, NULL, sshpam_thread, ctxt) == -1) {
+       result = pthread_create(&ctxt->pam_thread, NULL, sshpam_thread, ctxt);
+       if (result != 0) {
                error("PAM: failed to start authentication thread: %s",
-                   strerror(errno));
+                   strerror(result));
                close(socks[0]);
                close(socks[1]);
                free(ctxt);