From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: tim@sedlmeyer.us Return-Path: From: Tim Sedlmeyer MIME-Version: 1.0 Date: Sat, 27 Jan 2018 07:23:12 +0000 Message-ID: Subject: [PATCH] tools: fix removing preshared keys on some platforms To: WireGuard mailing list Content-Type: multipart/alternative; boundary="94eb2c1fb6c8582ac70563bce374" List-Id: Development discussion of WireGuard List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , --94eb2c1fb6c8582ac70563bce374 Content-Type: text/plain; charset="UTF-8" errno is checked following fread of the preshared key file. fread doesn't set errno, so it shouldn't be checked. On the EdgeRouter ER-X when wg uses glibc instead of musl libc this incorrect check causes removal of preshared keys to fail. This patch removes the check of errno. --- src/tools/config.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/tools/config.c b/src/tools/config.c index 5ab6ece..0407b36 100644 --- a/src/tools/config.c +++ b/src/tools/config.c @@ -128,10 +128,6 @@ static bool parse_keyfile(uint8_t key[static WG_KEY_LEN], const char *path) } if (fread(dst, WG_KEY_LEN_BASE64 - 1, 1, f) != 1) { - if (errno) { - perror("fread"); - goto out; - } /* If we're at the end and we didn't read anything, we're /dev/null or an empty file. */ if (!ferror(f) && feof(f) && !ftell(f)) { memset(key, 0, WG_KEY_LEN); -- 2.16.1 --94eb2c1fb6c8582ac70563bce374 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
errno is checked following fread of the preshared key file= . fread doesn't set errno, so it shouldn't be checked. On the EdgeR= outer ER-X when wg uses glibc instead of musl libc this incorrect check cau= ses removal of preshared keys to fail. This patch removes the check of errn= o.
=C2=A0=C2=A0
---
=C2=A0src/tools/config.c | = 4 ----
=C2=A01 file changed, 4 deletions(-)

<= div>diff --git a/src/tools/config.c b/src/tools/config.c
index 5a= b6ece..0407b36 100644
--- a/src/tools/config.c
+++ b/sr= c/tools/config.c
@@ -128,10 +128,6 @@ static bool parse_keyfile(u= int8_t key[static WG_KEY_LEN], const char *path)
=C2=A0 =C2=A0 = =C2=A0 =C2=A0 }

=C2=A0 =C2=A0 =C2=A0 =C2=A0 if (fr= ead(dst, WG_KEY_LEN_BASE64 - 1, 1, f) !=3D 1) {
-=C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if (errno) {
-=C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0pe= rror("fread");
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0goto out;
-=C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0}
=C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 /* If we're at the end and we= didn't read anything, we're /dev/null or an empty file. */
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if (!ferror(f) &= amp;& feof(f) && !ftell(f)) {
=C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 memset(key, = 0, WG_KEY_LEN);
--
2.16.1
--94eb2c1fb6c8582ac70563bce374--