diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2016-07-03 20:06:33 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2016-07-03 20:45:48 +0200 |
commit | 62cc3a9c5af2fd7cc8847a577b6b911c79e110e7 (patch) | |
tree | b11d05c7cd25c86aeb7cf8b3315e6f09f407a0f8 /src/tools/config.c | |
parent | tai64n: don't forget to add 2^62, to be in spec (diff) | |
download | wireguard-monolithic-historical-62cc3a9c5af2fd7cc8847a577b6b911c79e110e7.tar.xz wireguard-monolithic-historical-62cc3a9c5af2fd7cc8847a577b6b911c79e110e7.zip |
tools: improve error reporting and detection
Diffstat (limited to '')
-rw-r--r-- | src/tools/config.c | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/src/tools/config.c b/src/tools/config.c index 0cec30e..9066178 100644 --- a/src/tools/config.c +++ b/src/tools/config.c @@ -93,12 +93,8 @@ static inline uint16_t parse_port(const char *value) static inline bool parse_key(uint8_t key[WG_KEY_LEN], const char *value) { uint8_t tmp[WG_KEY_LEN + 1]; - if (strlen(value) != b64_len(WG_KEY_LEN) - 1) { - fprintf(stderr, "Key is not the correct length: `%s`\n", value); - return false; - } - if (b64_pton(value, tmp, WG_KEY_LEN + 1) < 0) { - fprintf(stderr, "Could not parse base64 key: `%s`\n", value); + if (strlen(value) != b64_len(WG_KEY_LEN) - 1 || b64_pton(value, tmp, WG_KEY_LEN + 1) != WG_KEY_LEN) { + fprintf(stderr, "Key is not the correct length or format: `%s`\n", value); return false; } memcpy(key, tmp, WG_KEY_LEN); |