Bug#768218: netcfg segfaults when passed four or more nameservers
Package: netcfg
Version: 1.108+deb7u2
Tags: patch
When passed more than three nameservers, netcfg can segfaults in
nm_write_static_ipvX due to a missing array bounds check. The attached
patch (against current git master) should fix the issue.
Cheers
From f729be186bf9b99c3ee7b0f05543f18d79737cfc Mon Sep 17 00:00:00 2001
From: Kjell Braden <afflux@pentabarf.de>
Date: Thu, 6 Nov 2014 02:05:28 +0100
Subject: [PATCH] fix missing bounds check on nameserver array iteration
---
nm-conf.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/nm-conf.c b/nm-conf.c
index 09b2fb4..db42c2c 100644
--- a/nm-conf.c
+++ b/nm-conf.c
@@ -88,7 +88,8 @@ void nm_write_static_ipvX(FILE *config_file, nm_ipvX ipvx)
/* Get DNS in printable format. */
memset(buffer, 0, NM_MAX_LEN_BUF);
- for (i = 0; !empty_str(ipvx.nameservers[i]); i++) {
+ for (i = 0; (i < NETCFG_NAMESERVERS_MAX) &&
+ (!empty_str(ipvx.nameservers[i])); i++) {
strcat(buffer, ipvx.nameservers[i]);
strcat(buffer, ";");
}
--
1.7.10.4
Reply to: