summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorStefan Fritsch <sf@cvs.openbsd.org>2018-07-03 16:42:52 +0000
committerStefan Fritsch <sf@cvs.openbsd.org>2018-07-03 16:42:52 +0000
commitf1e56339a425270bd2f8c5ab55a70d903416d413 (patch)
treeefc645aff8b5250f94f4dad189e4164155dcacb3 /usr.sbin
parenta7eb284df716f5332d0fc651c6ce93a8e5fbdee8 (diff)
hostctl: Don't crash if key is empty string
ok reyk@
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/hostctl/hostctl.c5
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);
}