krb5 commit: Fix spurious errors from kcmio_unix_socket_write

Greg Hudson <[email protected]>
Newsgroups gmane.comp.encryption.kerberos.cvs
Message-ID <[email protected]>
https://github.com/krb5/krb5/commit/3e76ea104cdaf22c4537833b203f8aeed1691f18
commit 3e76ea104cdaf22c4537833b203f8aeed1691f18
Author: Robbie Harwood <[email protected]>
Date:   Mon Nov 5 13:49:52 2018 -0500

    Fix spurious errors from kcmio_unix_socket_write
    
    Commit 33634a940166d0b21c3105bab8dcf5550fbbd678 accidentally changed
    the return value from kcmio_unix_socket_write to be the result of the
    write call.  Most commonly this resulted in it returning 8, which led
    to many commands failing with "Exec format error".
    
    ticket: 8758 (new)
    tags: pullup
    target_version: 1.17-next

 src/lib/krb5/ccache/cc_kcm.c |    7 +++----
 1 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/src/lib/krb5/ccache/cc_kcm.c b/src/lib/krb5/ccache/cc_kcm.c
index 2b9f82e..092ab7d 100644
--- a/src/lib/krb5/ccache/cc_kcm.c
+++ b/src/lib/krb5/ccache/cc_kcm.c
@@ -308,8 +308,9 @@ kcmio_unix_socket_write(krb5_context context, struct kcmio *io, void *request,
 
     for (;;) {
         ret = krb5int_net_writev(context, io->fd, sg, 2);
-        if (ret < 0)
-            ret = errno;
+        if (ret >= 0)
+            return 0;
+        ret = errno;
         if (ret != EPIPE || reconnected)
             return ret;
 
@@ -327,8 +328,6 @@ kcmio_unix_socket_write(krb5_context context, struct kcmio *io, void *request,
             return ret;
         reconnected = TRUE;
     }
-
-    return ret;
 }
 
 /* Read a KCM reply: 4-byte big-endian length, 4-byte big-endian status code,
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.