diff options
author | sf <sf@openbsd.org> | 2018-07-03 16:42:51 +0000 |
---|---|---|
committer | sf <sf@openbsd.org> | 2018-07-03 16:42:51 +0000 |
commit | 2f9de9d284b7765445f4ece2f9cf8a0a440b880c (patch) | |
tree | 26ac55ed63d7d494938fef06f7dc049265360df2 | |
parent | Use LIST_FOREACH construct instead of homebrew loop. (diff) | |
download | wireguard-openbsd-2f9de9d284b7765445f4ece2f9cf8a0a440b880c.tar.xz wireguard-openbsd-2f9de9d284b7765445f4ece2f9cf8a0a440b880c.zip |
hostctl: Don't crash if key is empty string
ok reyk@
-rw-r--r-- | usr.sbin/hostctl/hostctl.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/usr.sbin/hostctl/hostctl.c b/usr.sbin/hostctl/hostctl.c index 081beffde6e..dbaf1eb0d6c 100644 --- a/usr.sbin/hostctl/hostctl.c +++ b/usr.sbin/hostctl/hostctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: hostctl.c,v 1.3 2016/01/27 16:01:36 jmc Exp $ */ +/* $OpenBSD: hostctl.c,v 1.4 2018/07/03 16:42:51 sf Exp $ */ /* * Copyright (c) 2016 Reyk Floeter <reyk@openbsd.org> @@ -59,8 +59,7 @@ kvsetstr(char *dst, const char *src, size_t dstlen) return (-1); /* Remove trailing newline */ - if (dst[sz - 1] == '\n') - dst[sz - 1] = '\0'; + dst[strcspn(dst, "\n")] = '\0'; return (0); } |