|
|
dc8c34 |
From 150020e636bb801fddf6bf4e9a71a6c27e8d9d07 Mon Sep 17 00:00:00 2001
|
|
|
dc8c34 |
From: Noriko Hosoi <nhosoi@redhat.com>
|
|
|
dc8c34 |
Date: Mon, 30 Sep 2013 12:45:15 -0700
|
|
|
dc8c34 |
Subject: [PATCH 138/225] Coverity fixes - 12023, 12024, and 12025
|
|
|
dc8c34 |
|
|
|
dc8c34 |
. 12023 - Ignoring number of bytes read
|
|
|
dc8c34 |
basicInit (ldclt.c):
|
|
|
dc8c34 |
The return value from fread was ignored and not used for copying
|
|
|
dc8c34 |
the read content from buffer to mctx.attrplFileContent.
|
|
|
dc8c34 |
. 12024 - Resource leak
|
|
|
dc8c34 |
roles_cache_create_object_from_entry (roles_cache.c):
|
|
|
dc8c34 |
When an error occurred, filter_attr_value was not freed.
|
|
|
dc8c34 |
|
|
|
dc8c34 |
Reviewed by rmeggins (Thank you, Rich!!)
|
|
|
dc8c34 |
(cherry picked from commit f702868012ac1f9deb1cb92d51cdfd793353e836)
|
|
|
dc8c34 |
(cherry picked from commit 99f7b65e4bd35ce5d2c24a05178cfca4a44645db)
|
|
|
dc8c34 |
(cherry picked from commit aa19f9ad2d2d1ee58fa2a0da3b6119a95ea47733)
|
|
|
dc8c34 |
(cherry picked from commit 2d588df1ab832d5027719c25a4b2477de22b5839)
|
|
|
dc8c34 |
---
|
|
|
dc8c34 |
ldap/servers/plugins/roles/roles_cache.c | 3 ++-
|
|
|
dc8c34 |
ldap/servers/slapd/tools/ldclt/ldclt.c | 14 +++++++++-----
|
|
|
dc8c34 |
2 files changed, 11 insertions(+), 6 deletions(-)
|
|
|
dc8c34 |
|
|
|
dc8c34 |
diff --git a/ldap/servers/plugins/roles/roles_cache.c b/ldap/servers/plugins/roles/roles_cache.c
|
|
|
dc8c34 |
index 83d3292..32ebf74 100644
|
|
|
dc8c34 |
--- a/ldap/servers/plugins/roles/roles_cache.c
|
|
|
dc8c34 |
+++ b/ldap/servers/plugins/roles/roles_cache.c
|
|
|
dc8c34 |
@@ -1224,6 +1224,7 @@ static int roles_cache_create_object_from_entry(Slapi_Entry *role_entry, role_ob
|
|
|
dc8c34 |
(char*)slapi_sdn_get_ndn(this_role->dn),
|
|
|
dc8c34 |
ROLE_FILTER_ATTR_NAME, filter_attr_value,
|
|
|
dc8c34 |
ROLE_FILTER_ATTR_NAME);
|
|
|
dc8c34 |
+ slapi_ch_free_string(&filter_attr_value);
|
|
|
dc8c34 |
slapi_ch_free((void**)&this_role);
|
|
|
dc8c34 |
return SLAPI_ROLE_ERROR_FILTER_BAD;
|
|
|
dc8c34 |
}
|
|
|
dc8c34 |
@@ -1233,7 +1234,7 @@ static int roles_cache_create_object_from_entry(Slapi_Entry *role_entry, role_ob
|
|
|
dc8c34 |
|
|
|
dc8c34 |
/* Turn it into a slapi filter object */
|
|
|
dc8c34 |
filter = slapi_str2filter(filter_attr_value);
|
|
|
dc8c34 |
- slapi_ch_free((void**)&filter_attr_value);
|
|
|
dc8c34 |
+ slapi_ch_free_string(&filter_attr_value);
|
|
|
dc8c34 |
|
|
|
dc8c34 |
if ( filter == NULL )
|
|
|
dc8c34 |
{
|
|
|
dc8c34 |
diff --git a/ldap/servers/slapd/tools/ldclt/ldclt.c b/ldap/servers/slapd/tools/ldclt/ldclt.c
|
|
|
dc8c34 |
index 2a45c76..7d22c2d 100644
|
|
|
dc8c34 |
--- a/ldap/servers/slapd/tools/ldclt/ldclt.c
|
|
|
dc8c34 |
+++ b/ldap/servers/slapd/tools/ldclt/ldclt.c
|
|
|
dc8c34 |
@@ -1572,20 +1572,24 @@ basicInit (void)
|
|
|
dc8c34 |
/* start to read file content */
|
|
|
dc8c34 |
mctx.attrplFileContent = (char *)malloc(mctx.attrplFileSize + 1);
|
|
|
dc8c34 |
i=0;
|
|
|
dc8c34 |
- while ( fread(buffer, BUFFERSIZE , 1, attrF) )
|
|
|
dc8c34 |
+ while ( (ret = fread(buffer, BUFFERSIZE , 1, attrF)) )
|
|
|
dc8c34 |
{
|
|
|
dc8c34 |
- memcpy(mctx.attrplFileContent+i, buffer , BUFFERSIZE );
|
|
|
dc8c34 |
- memset(buffer ,'\0', BUFFERSIZE );
|
|
|
dc8c34 |
- i = i + BUFFERSIZE;
|
|
|
dc8c34 |
+ memcpy(mctx.attrplFileContent+i, buffer , ret);
|
|
|
dc8c34 |
+ memset(buffer ,'\0', BUFFERSIZE);
|
|
|
dc8c34 |
+ i += ret;
|
|
|
dc8c34 |
}
|
|
|
dc8c34 |
/* copy remainding content into mctx.attrplFileContent */
|
|
|
dc8c34 |
+ /* ???
|
|
|
dc8c34 |
+ * Why you need to copy buffer twice to fill the gap?
|
|
|
dc8c34 |
+ * Could there any chance (mctx.attrplFileSize - 1 - i) > BUFFERSIZE ?
|
|
|
dc8c34 |
+ */
|
|
|
dc8c34 |
if (i
|
|
|
dc8c34 |
{
|
|
|
dc8c34 |
memcpy(mctx.attrplFileContent+i, buffer , (mctx.attrplFileSize - 1 - i));
|
|
|
dc8c34 |
memset(buffer ,'\0', BUFFERSIZE ); /* clear the buffer */
|
|
|
dc8c34 |
}
|
|
|
dc8c34 |
|
|
|
dc8c34 |
- mctx.attrplFileContent[mctx.attrplFileSize]='\0'; // append the close bit
|
|
|
dc8c34 |
+ mctx.attrplFileContent[mctx.attrplFileSize]='\0'; /* append the close bit */
|
|
|
dc8c34 |
|
|
|
dc8c34 |
if ((fclose(attrF)) == EOF )
|
|
|
dc8c34 |
{
|
|
|
dc8c34 |
--
|
|
|
dc8c34 |
1.8.1.4
|
|
|
dc8c34 |
|