be more tolerant when reading key fingerprint
authorDaniel Golle <daniel@makrotopia.org>
Tue, 18 Sep 2018 11:29:10 +0000 (13:29 +0200)
committerDaniel Golle <daniel@makrotopia.org>
Tue, 18 Sep 2018 11:34:26 +0000 (13:34 +0200)
usign occasionally writes 16 characters then exits without writing a LF,
leaving ucert hanging waiting for more input.  Accept 16 characters
or more rather than 17 to work around the short read.

Signed-off-by: Mike McCormack <mike@atratus.org>
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
usign-exec.c

index 21a24c2c7bf5a3031b1292aca12c11fc78b3a95b..949e83e7395981e2592add724bc5c712bb30060f 100644 (file)
@@ -156,9 +156,10 @@ static int usign_f(char *fingerprint, const char *pubkeyfile, const char *seckey
                waitpid(pid, &status, 0);
                status = WEXITSTATUS(status);
                if (fingerprint && !WEXITSTATUS(status)) {
+                       ssize_t r;
                        memset(fingerprint, 0, 17);
-                       read(fds[0], fingerprint, 17);
-                       if (fingerprint[16] != '\n')
+                       r = read(fds[0], fingerprint, 17);
+                       if (r < 16)
                                status = -1;
 
                        fingerprint[16] = '\0';