From mboxrd@z Thu Jan 1 00:00:00 1970 Received: by passt.top (Postfix, from userid 1000) id 182C85A004E; Thu, 27 Jun 2024 22:46:41 +0200 (CEST) From: Stefano Brivio To: passt-dev@passt.top Subject: [PATCH v2 1/5] conf: Copy up to MAXDNSRCH - 1 bytes, not MAXDNSRCH Date: Thu, 27 Jun 2024 22:46:37 +0200 Message-ID: <20240627204641.4046184-2-sbrivio@redhat.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240627204641.4046184-1-sbrivio@redhat.com> References: <20240627204641.4046184-1-sbrivio@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: ZDDZC5UM7HF2WIKRQLLHGYVBSKO4BARK X-Message-ID-Hash: ZDDZC5UM7HF2WIKRQLLHGYVBSKO4BARK X-MailFrom: sbrivio@passt.top X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Matej Hrica , David Gibson X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Spotted by Coverity just recently. Not that it really matters as MAXDNSRCH always appears to be defined as 1025, while a full domain name can have up to 253 characters: it would be a bit pointless to have a longer search domain. Signed-off-by: Stefano Brivio Reviewed-by: David Gibson --- conf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf.c b/conf.c index e1f5422..9e47e9a 100644 --- a/conf.c +++ b/conf.c @@ -453,7 +453,7 @@ static void get_dns(struct ctx *c) while (s - c->dns_search < ARRAY_SIZE(c->dns_search) - 1 /* cppcheck-suppress strtokCalled */ && (p = strtok(NULL, " \t"))) { - strncpy(s->n, p, sizeof(c->dns_search[0])); + strncpy(s->n, p, sizeof(c->dns_search[0]) - 1); s++; *s->n = 0; } -- 2.43.0