usign-exec: improve usign -F output handling
authorMatthias Schiffer <mschiffer@universe-factory.net>
Sat, 16 May 2020 16:53:40 +0000 (18:53 +0200)
committerMatthias Schiffer <mschiffer@universe-factory.net>
Sat, 16 May 2020 16:53:40 +0000 (18:53 +0200)
commitfe06b4b836b3afd5b27039914dea1c7fe20bd78d
treeb3ee0867a47b5f86db56233cc66a350d97384558
parent19f9e1917e1b458ed3b80d0d0295d62ae3ee3185
usign-exec: improve usign -F output handling

While not likely to happen in pratice, nothing guarantees that read()
will retrieve more than 1 byte at a time. The easiest way to make this
code compliant is to wrap the file descriptor using fdopen().

While we're at it, also
- remove useless memset()
- check fingerprint for validity

The check is particularly relevant, as a usign bug [1] causing short
fingerprint outputs only went unnoticed for so long because the trailing
newline was considered one of the 16 characters ucert was expecting.

[1] https://patchwork.ozlabs.org/project/openwrt/patch/8ead1fd6a61117b54b4efd5111fe0d19e4eef9c5.1589642591.git.mschiffer@universe-factory.net/

Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
usign-exec.c