From: Guus Sliepen Date: Mon, 16 Feb 2015 07:42:30 +0000 (+0100) Subject: Suppress warnings about parsing Ed25519 keys when they are not present. X-Git-Tag: release-1.1pre12~201 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=cffcaf966b65a61943a00120f1ec5c868c917c1f;p=oweals%2Ftinc.git Suppress warnings about parsing Ed25519 keys when they are not present. --- diff --git a/src/ed25519/ecdsa.c b/src/ed25519/ecdsa.c index bfdabc1..f8aafe4 100644 --- a/src/ed25519/ecdsa.c +++ b/src/ed25519/ecdsa.c @@ -84,11 +84,13 @@ static bool read_pem(FILE *fp, const char *type, void *buf, size_t size) { size_t len = b64decode(line, line, linelen); if(!len) { logger(DEBUG_ALWAYS, LOG_ERR, "Invalid base64 data in PEM file\n"); + errno = EINVAL; return false; } if(len > size) { logger(DEBUG_ALWAYS, LOG_ERR, "Too much base64 data in PEM file\n"); + errno = EINVAL; return false; } @@ -98,7 +100,12 @@ static bool read_pem(FILE *fp, const char *type, void *buf, size_t size) { } if(size) { - logger(DEBUG_ALWAYS, LOG_ERR, "Too little base64 data in PEM file\n"); + if(data) { + errno = EINVAL; + logger(DEBUG_ALWAYS, LOG_ERR, "Too little base64 data in PEM file\n"); + } else { + errno = ENOENT; + } return false; } diff --git a/src/net_setup.c b/src/net_setup.c index 7f51fe4..d1d5c04 100644 --- a/src/net_setup.c +++ b/src/net_setup.c @@ -137,10 +137,11 @@ bool read_ecdsa_public_key(connection_t *c) { } c->ecdsa = ecdsa_read_pem_public_key(fp); - fclose(fp); - if(!c->ecdsa) + if(!c->ecdsa && errno != ENOENT) logger(DEBUG_ALWAYS, LOG_ERR, "Parsing Ed25519 public key file `%s' failed.", fname); + + fclose(fp); free(fname); return c->ecdsa; }