ldap/servers/plugins/uiduniq/uid.c | 10 ++--------
ldap/servers/slapd/task.c | 10 ++++++----
2 files changed, 8 insertions(+), 12 deletions(-)
New commits:
commit 03f85ec06f6011e1573980e87319af2043e03948
Author: Noriko Hosoi <nhosoi(a)redhat.com>
Date: Mon Jul 14 10:43:21 2014 -0700
Ticket #47859 - Coverity: 12692 & 12717
12717 - Resource leak - servers/plugins/uiduniq/uid.c
Description: In uniqueness_entry_to_config, the return value of
slapi_ch_calloc was checked if it was NULL or not. If NULL, the
function returned without releasing values. This patch remove the
NULL check and error return since the 2 arguments (i + 1, sizeof
(Slapi_DN *)) never be 0 or negative, thus slapi_ch_calloc has no
chance to return NULL. If allocation fails, it exits there.
Note: introduced by commit c66b5e9f83a81d75d8137e86b5e7631507592099
(ticket #47823)
https://fedorahosted.org/389/ticket/47859
Reviewed by rmeggins(a)redhat.com (Thank you, Rich!!)
diff --git a/ldap/servers/plugins/uiduniq/uid.c b/ldap/servers/plugins/uiduniq/uid.c
index f4a9a8d..d1a1700 100644
--- a/ldap/servers/plugins/uiduniq/uid.c
+++ b/ldap/servers/plugins/uiduniq/uid.c
@@ -223,15 +223,9 @@ uniqueness_entry_to_config(Slapi_PBlock *pb, Slapi_Entry
*config_entry)
/* Subtrees where uniqueness is tested */
values = slapi_entry_attr_get_charray(config_entry,
ATTR_UNIQUENESS_SUBTREES);
if (values) {
-
-
for (i = 0; values && values[i]; i++);
- if ((tmp_config->subtrees = (Slapi_DN **) slapi_ch_calloc(i +
1, sizeof (Slapi_DN *))) == NULL) {
- slapi_log_error(SLAPI_LOG_FATAL, plugin_name,
"Config info: Fail to allocate subtree array \n");
- rc = SLAPI_PLUGIN_FAILURE;
- goto done;
- }
-
+ /* slapi_ch_calloc never returns NULL unless the 2 args are 0 or
negative. */
+ tmp_config->subtrees = (Slapi_DN **) slapi_ch_calloc(i + 1,
sizeof (Slapi_DN *)));
/* copy the valid subtree DN into the config */
for (i = 0, nb_subtrees = 0; values && values[i]; i++) {
if (slapi_dn_syntax_check(pb, values[i], 1)) { /* syntax
check failed */
commit 1e0dc9e20d794e803063f98f964e711d56898891
Author: Noriko Hosoi <nhosoi(a)redhat.com>
Date: Mon Jul 14 10:11:28 2014 -0700
Revert "Revert "Ticket #47835 - Coverity: 12687..12692""
This reverts commit 8247976f25c22799a31be08074cc150e07f5dcce.
Note: It turned out this patch is necessary even if Coverity filter is enhanced.
12692 - Use of untrusted string value
Description: lines read from the sysconfig reload task's attribute
sysconfigfile (e.g., /etc/sysconfig/dirsrv-localhost) could be tainted.
Check the end of the line more rigorously, and eliminate a chance to
overflow env_var and env_value by copying the characters from read
line.
Reviewed by rmeggins(a)redhat.com (Thanks, Rich!)
https://fedorahosted.org/389/ticket/47835
diff --git a/ldap/servers/slapd/task.c b/ldap/servers/slapd/task.c
index 489266f..1089353 100644
--- a/ldap/servers/slapd/task.c
+++ b/ldap/servers/slapd/task.c
@@ -1954,6 +1954,8 @@ task_sysconfig_reload_add(Slapi_PBlock *pb, Slapi_Entry *e,
Slapi_Entry *eAfter,
if ( file != NULL ){
char line[4096];
char *s = NULL;
+ /* fgets() reads in at most one less than size characters */
+ char *end_of_line = line + sizeof(line) - 1;
if(logchanges){
LDAPDebug(LDAP_DEBUG_ANY, "sysconfig reload task: processing file
(%s)\n",
@@ -1965,8 +1967,8 @@ task_sysconfig_reload_add(Slapi_PBlock *pb, Slapi_Entry *e,
Slapi_Entry *eAfter,
/* skip comments */
continue;
} else {
- char env_value[4096];
- char env_var[4096];
+ char env_value[sizeof(line)];
+ char env_var[sizeof(line)];
int using_setenv = 0;
int value_index = 0;
int start_value = 0;
@@ -2002,7 +2004,7 @@ task_sysconfig_reload_add(Slapi_PBlock *pb, Slapi_Entry *e,
Slapi_Entry *eAfter,
using_setenv = 1;
}
if(strncmp(s, "export ", 7) == 0){
- /* strip off "export " */
+ /* strip off "export " */
s = s + 7;
} else if(strncmp(s, "set ", 4) == 0){
/* strip off "set " */
@@ -2026,7 +2028,7 @@ task_sysconfig_reload_add(Slapi_PBlock *pb, Slapi_Entry *e,
Slapi_Entry *eAfter,
/*
* Start parsing the names and values
*/
- for (; s && *s; s++){
+ for (; s && (s < end_of_line) && *s; s++){
/*
* If using "setenv", allow the first space/tab only, and
start on the env value
*/