ldap/servers/slapd/back-ldbm/ldbm_attrcrypt.c | 4 ++--
ldap/servers/slapd/uuid.c | 13 +++++++------
ldap/servers/slapd/vattr.c | 2 +-
3 files changed, 10 insertions(+), 9 deletions(-)
New commits:
commit 5b6d116d6a8ec7823f6f806277069e153b46e734
Author: Nathan Kinder <nkinder(a)redhat.com>
Date: Fri Mar 25 10:40:52 2011 -0700
Bug 690882 - (cov#10572,10710) Incorrect sizeof use in uuid code
When sizeof() is called at line 943, it is calculating the size of
a pointer, not the array. This happens since the array was passed
to get_random_info(), which considers it to just be a pointer. The
result is that we do not fill in the full array with random data.
We should pass the array length to this function instead of using
sizeof().
diff --git a/ldap/servers/slapd/uuid.c b/ldap/servers/slapd/uuid.c
index c19648f..4a3ec8e 100644
--- a/ldap/servers/slapd/uuid.c
+++ b/ldap/servers/slapd/uuid.c
@@ -89,6 +89,7 @@
#define MODULE "uuid" /* for logging */
#define UPDATE_INTERVAL 60000 /* 1 minute */
#define NEED_TIME_UPDATE -1
+#define SEED_LENGTH 16
/* generates uuid in singlethreaded environment */
static int uuid_create_st(guid_t *uuid);
@@ -127,7 +128,7 @@ static void get_system_time(uuid_time_t *uuid_time);
/* generates random value - used to set clock sequence */
static unsigned16 true_random(void);
/* generate random info buffer to generate nodeid */
-static void get_random_info(unsigned char seed[16]);
+static void get_random_info(unsigned char seed[], size_t arraylen);
/* UUID generator state stored persistently */
typedef struct
@@ -890,7 +891,7 @@ static void format_uuid_v3(guid_t * uuid, unsigned char hash[16])
*/
static int get_node_identifier (uuid_node_t *node)
{
- unsigned char seed[16]= {0};
+ unsigned char seed[SEED_LENGTH]= {0};
#ifdef USE_NIC
/* ONREPL - code to use NIC address would go here; Currently, we use
@@ -899,7 +900,7 @@ static int get_node_identifier (uuid_node_t *node)
docs for more info.
*/
#endif
- get_random_info(seed);
+ get_random_info(seed, SEED_LENGTH);
seed[0] |= 0x80;
memcpy (node, seed, sizeof (uuid_node_t));
@@ -938,7 +939,7 @@ static unsigned16 true_random(void)
return (slapi_rand_r(&uuid_seed));
}
-static void get_random_info(unsigned char seed[16])
+static void get_random_info(unsigned char seed[], size_t arraylen)
{
- slapi_rand_array(seed, sizeof(seed));
+ slapi_rand_array(seed, arraylen);
}
commit 3e9fa7ada315098b9e18b4ed30e777170314c2cb
Author: Nathan Kinder <nkinder(a)redhat.com>
Date: Fri Mar 25 10:11:17 2011 -0700
Bug 690882 - (cov#10703) Incorrect sizeof use in vattr code
We are using sizeof() incorrectly when allocating memory for an
array of integers. We are currently getting the sizeof a pointer
to an int instead of the size of an int itself.
diff --git a/ldap/servers/slapd/vattr.c b/ldap/servers/slapd/vattr.c
index e221096..2961ea4 100644
--- a/ldap/servers/slapd/vattr.c
+++ b/ldap/servers/slapd/vattr.c
@@ -1705,7 +1705,7 @@ int vattr_call_sp_get_batch_values(vattr_sp_handle *handle,
vattr_context *c, Sl
{
/* make our args look like the simple non-batched case */
*results = (Slapi_ValueSet**)slapi_ch_calloc(2, sizeof(**results)); /* 2 for null
terminated list */
- *type_name_disposition = (int *)slapi_ch_calloc(2, sizeof(*type_name_disposition));
+ *type_name_disposition = (int *)slapi_ch_calloc(2, sizeof(**type_name_disposition));
*actual_type_name = (char**)slapi_ch_calloc(2, sizeof(**actual_type_name));
ret
=((handle->sp->sp_get_fn)(handle,c,e,*type,*results,*type_name_disposition,*actual_type_name,flags,buffer_flags,
hint));
commit 0d327240c853bb2c06dc9fdec39e1e649a363c18
Author: Nathan Kinder <nkinder(a)redhat.com>
Date: Fri Mar 25 10:07:14 2011 -0700
Bug 690882 - (cov#10636,10637) Useless comparison in attrcrypt
The backend attribute encryption code makes a useless comparison
when doing error checking. We are comparing an array with NULL,
but an array will always be non-NULL, so we can just check if
state_priv is NULL.
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_attrcrypt.c
b/ldap/servers/slapd/back-ldbm/ldbm_attrcrypt.c
index 9f22a58..f700434 100644
--- a/ldap/servers/slapd/back-ldbm/ldbm_attrcrypt.c
+++ b/ldap/servers/slapd/back-ldbm/ldbm_attrcrypt.c
@@ -1116,7 +1116,7 @@ back_crypt_encrypt_value(void *handle, struct berval *in, struct
berval **out)
goto bail;
}
*out = NULL;
- if (!state_priv || !state_priv->acs_array) {
+ if (!state_priv) {
goto bail;
}
invalue = slapi_value_new_berval(in);
@@ -1147,7 +1147,7 @@ back_crypt_decrypt_value(void *handle, struct berval *in, struct
berval **out)
goto bail;
}
*out = NULL;
- if (!state_priv || !state_priv->acs_array) {
+ if (!state_priv) {
goto bail;
}
invalue = slapi_value_new_berval(in);
commit 76561dba969d39ef6f792adb0338c9ccdfa7c04e
Author: Nathan Kinder <nkinder(a)redhat.com>
Date: Fri Mar 25 10:00:37 2011 -0700
Bug 690882 - (cov#10571) Incorrect sizeof use in uuid code
It looks like the caller wanted to clear out the uuid struct if
there was a problem creating the NSS context. The problem is that
the memset at line 341 is only clearing out the local pointer to
the struct. This local pointer is never seen by the caller and the
struct retains whetever it previously held in memory. We need to
clear out the contents of the struct itself instead of just
clearing the address held by the local pointer.
diff --git a/ldap/servers/slapd/uuid.c b/ldap/servers/slapd/uuid.c
index 5e26be2..c19648f 100644
--- a/ldap/servers/slapd/uuid.c
+++ b/ldap/servers/slapd/uuid.c
@@ -338,7 +338,7 @@ void uuid_create_from_name(guid_t * uuid, /* resulting UUID */
PK11_DestroyContext(c, PR_TRUE);
}
else { /* Probably desesperate but at least deterministic... */
- memset(&uuid, 0, sizeof(uuid));
+ memset(uuid, 0, sizeof(*uuid));
}
}