900526
From 1f3ac11cb4ecfab52f517ebf78493b0f05318be2 Mon Sep 17 00:00:00 2001
900526
From: Evan Hunt <each@isc.org>
900526
Date: Mon, 16 Jun 2014 15:31:04 -0700
900526
Subject: [PATCH] [v9_9] null terminate strings for coverity
900526
900526
---
900526
 bin/dig/dig.c                         | 1 +
900526
 bin/tests/system/dlzexternal/driver.c | 6 ++++++
900526
 2 files changed, 7 insertions(+)
900526
900526
diff --git a/bin/dig/dig.c b/bin/dig/dig.c
900526
index 8a5fead..6af0964 100644
900526
--- a/bin/dig/dig.c
900526
+++ b/bin/dig/dig.c
900526
@@ -1453,6 +1453,7 @@ dash_option(char *option, char *next, dig_lookup_t **lookup,
900526
 				ip6_int, ISC_FALSE) == ISC_R_SUCCESS) {
900526
 			strncpy((*lookup)->textname, textname,
900526
 				sizeof((*lookup)->textname));
900526
+			(*lookup)->textname[sizeof((*lookup)->textname)-1] = 0;
900526
 			debug("looking up %s", (*lookup)->textname);
900526
 			(*lookup)->trace_root = ISC_TF((*lookup)->trace  ||
900526
 						(*lookup)->ns_search_only);
900526
diff --git a/bin/tests/system/dlzexternal/driver.c b/bin/tests/system/dlzexternal/driver.c
900526
index 053c25a..f99ac14 100644
900526
--- a/bin/tests/system/dlzexternal/driver.c
900526
+++ b/bin/tests/system/dlzexternal/driver.c
900526
@@ -133,8 +133,14 @@ add_name(struct dlz_example_data *state, struct record *list,
900526
 		return (ISC_R_NOSPACE);
900526
 
900526
 	strncpy(list[i].name, name, sizeof(list[i].name));
900526
+	list[i].name[sizeof(list[i].name) - 1] = '\0';
900526
+
900526
 	strncpy(list[i].type, type, sizeof(list[i].type));
900526
+	list[i].type[sizeof(list[i].type) - 1] = '\0';
900526
+
900526
 	strncpy(list[i].data, data, sizeof(list[i].data));
900526
+	list[i].data[sizeof(list[i].data) - 1] = '\0';
900526
+
900526
 	list[i].ttl = ttl;
900526
 
900526
 	return (ISC_R_SUCCESS);
900526
-- 
900526
2.9.3
900526