From 08800e61eaba05265d3d976b0e9922f9bc4c63b2 Mon Sep 17 00:00:00 2001 From: Petr Mensik Date: Mon, 18 Feb 2019 20:27:18 +0100 Subject: [PATCH] Always produce zero terminated address --- lib/backend.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/backend.c b/lib/backend.c index 1b3dadc..b895651 100644 --- a/lib/backend.c +++ b/lib/backend.c @@ -287,8 +287,10 @@ netresolve_backend_add_path(netresolve_query_t query, if (length) memcpy(path.node.address, address, length); - else - strncpy(path.node.address, address, sizeof path.node.address); + else { + path.node.address[sizeof(path.node.address)-1] = 0; + strncpy(path.node.address, address, sizeof(path.node.address)-1); + } if (query->request.servname && (!socktype || !protocol || !port)) { struct path_data data = { .query = query, .path = &path }; -- 2.20.1