FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Redhat > Cluster Development

 
 
LinkBack Thread Tools
 
Old 10-25-2011, 12:09 PM
"Fabio M. Di Nitto"
 
Default config: make sure error reporting does not overflow buffers

Spotted by Coverity Scan

Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>
---
:100644 100644 49c30b7... c9ba2bf... M config/plugins/ldap/configldap.c
config/plugins/ldap/configldap.c | 12 ++++++------
1 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/config/plugins/ldap/configldap.c b/config/plugins/ldap/configldap.c
index 49c30b7..c9ba2bf 100644
--- a/config/plugins/ldap/configldap.c
+++ b/config/plugins/ldap/configldap.c
@@ -67,7 +67,7 @@ static int ldap_readconfig(struct objdb_iface_ver0 *objdb, const char **error_st

/* Read config tree from LDAP */
if (!(ret = init_config(objdb)))
- sprintf(error_reason, "%s", "Successfully read config from LDAP
");
+ snprintf(error_reason, sizeof(error_reason), "%s", "Successfully read config from LDAP
");

*error_string = error_reason;

@@ -156,13 +156,13 @@ static int read_config_for(LDAP *ld, struct objdb_iface_ver0 *objdb, hdb_handle_
hdb_handle_t parent_handle = OBJECT_PARENT_HANDLE;
hdb_handle_t object_handle;

- sprintf(search_dn, "%s,%s", sub_dn, ldap_basedn);
+ snprintf(search_dn, sizeof(search_dn), "%s,%s", sub_dn, ldap_basedn);

/* Search the whole tree from the base DN provided */
rc = ldap_search_ext_s(ld, search_dn, LDAP_SCOPE_SUBTREE, "(objectClass=*)", NULL, 0,
NULL, NULL, NULL, 0, &result);
if (rc != LDAP_SUCCESS) {
- sprintf(error_reason, "ldap_search_ext_s: %s
", ldap_err2string(rc));
+ snprintf(error_reason, sizeof(error_reason), "ldap_search_ext_s: %s
", ldap_err2string(rc));
if (rc == LDAP_NO_SUCH_OBJECT)
return 0;
else
@@ -177,7 +177,7 @@ static int read_config_for(LDAP *ld, struct objdb_iface_ver0 *objdb, hdb_handle_

/* Make it parsable so we can discern the hierarchy */
if (ldap_str2dn(dn, &parsed_dn, LDAP_DN_PEDANTIC)) {
- sprintf(error_reason, "ldap_str2dn failed: %s
", ldap_err2string(rc));
+ snprintf(error_reason, sizeof(error_reason), "ldap_str2dn failed: %s
", ldap_err2string(rc));
return -1;
}

@@ -273,7 +273,7 @@ static int init_config(struct objdb_iface_ver0 *objdb)

/* Connect to the LDAP server */
if (ldap_initialize(&ld, ldap_url)) {
- sprintf(error_reason, "ldap_initialize failed: %s
", strerror(errno));
+ snprintf(error_reason, sizeof(error_reason), "ldap_initialize failed: %s
", strerror(errno));
return -1;
}
version = LDAP_VERSION3;
@@ -284,7 +284,7 @@ static int init_config(struct objdb_iface_ver0 *objdb)
*/
rc = ldap_simple_bind_s(ld, getenv("COROSYNC_LDAP_BINDDN"), getenv("COROSYNC_LDAP_BINDPWD"));
if (rc != LDAP_SUCCESS) {
- sprintf(error_reason, "ldap_simple_bind failed: %s
", ldap_err2string(rc));
+ snprintf(error_reason, sizeof(error_reason), "ldap_simple_bind failed: %s
", ldap_err2string(rc));
return -1;
}

--
1.7.4.4
 
Old 10-25-2011, 12:09 PM
"Fabio M. Di Nitto"
 
Default config: make sure error reporting does not overflow buffers

Spotted by Coverity Scan

Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>
---
:100644 100644 9479bc2... a25df09... M config/plugins/xml/config.c
config/plugins/xml/config.c | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/config/plugins/xml/config.c b/config/plugins/xml/config.c
index 9479bc2..a25df09 100644
--- a/config/plugins/xml/config.c
+++ b/config/plugins/xml/config.c
@@ -106,11 +106,11 @@ static int xml_readconfig(struct objdb_iface_ver0 *objdb, const char **error_str

/* Read low-level totem/aisexec etc config from cluster.conf */
if (!(ret = init_config(objdb, configfile, error_reason)))
- sprintf(error_reason, "Successfully read config from %s
",
- configfile);
+ snprintf(error_reason, sizeof(error_reason),
+ "Successfully read config from %s
", configfile);
else
- sprintf(error_reason, "Unable to read config from %s
",
- configfile);
+ snprintf(error_reason, sizeof(error_reason),
+ "Unable to read config from %s
", configfile);

*error_string = error_reason;

--
1.7.4.4
 

Thread Tools




All times are GMT. The time now is 06:26 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org