be more tolerant when reading key fingerprint master
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 21a24c2..949e83e 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';