Linux Archive

Linux Archive (http://www.linux-archive.org/)
-   Cluster Development (http://www.linux-archive.org/cluster-development/)
-   -   config: fix a few theoretical buffer overflows (http://www.linux-archive.org/cluster-development/591087-config-fix-few-theoretical-buffer-overflows.html)

"Fabio M. Di Nitto" 10-25-2011 12:09 PM

config: fix a few theoretical buffer overflows
 
Spotted by Coverity Scan

Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>
---
:100644 100644 12c5320... 12536ae... M config/libs/libccsconfdb/extras.c
config/libs/libccsconfdb/extras.c | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/config/libs/libccsconfdb/extras.c b/config/libs/libccsconfdb/extras.c
index 12c5320..12536ae 100644
--- a/config/libs/libccsconfdb/extras.c
+++ b/config/libs/libccsconfdb/extras.c
@@ -65,7 +65,7 @@ int ccs_lookup_nodename(int cd, const char *nodename, char **retval)
}

/* Try just the hostname */
- strcpy(host_only, nodename);
+ strncpy(host_only, nodename, sizeof(host_only) - 1);
p = strchr(host_only, '.');
if (p != NULL) {
*p = '';
@@ -134,7 +134,7 @@ int ccs_lookup_nodename(int cd, const char *nodename, char **retval)
errno = E2BIG;
return -1;
}
- strcpy(canonical_name, str);
+ strncpy(canonical_name, str, sizeof(canonical_name) - 1);
}

if (strlen(str) >= sizeof(cur_node)) {
@@ -143,7 +143,7 @@ int ccs_lookup_nodename(int cd, const char *nodename, char **retval)
return -1;
}

- strcpy(cur_node, str);
+ strncpy(cur_node, str, sizeof(cur_node) - 1);

p = strchr(cur_node, '.');
if (p != NULL)
--
1.7.4.4


All times are GMT. The time now is 11:28 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.