diff --git a/src/openvpn/buffer.h b/src/openvpn/buffer.h
index a4fe6f9b..52de5a2b 100644
--- a/src/openvpn/buffer.h
+++ b/src/openvpn/buffer.h
@@ -347,7 +347,8 @@ buf_set_read(struct buffer *buf, const uint8_t *data, int size)
 static inline void
 strncpynt(char *dest, const char *src, size_t maxlen)
 {
-    strncpy(dest, src, maxlen);
+    ASSERT(maxlen>0);
+    strncpy(dest, src, maxlen-1);
     if (maxlen > 0)
     {
         dest[maxlen - 1] = 0;
