ldap/servers/slapd/daemon.c | 2 +-
ldap/servers/slapd/entry.c | 14 ++++++++++++++
ldap/servers/slapd/libglobs.c | 14 ++++++++++----
ldap/servers/slapd/proto-slap.h | 2 +-
ldap/servers/slapd/slap.h | 2 +-
ldap/servers/slapd/slapi-plugin.h | 10 ++++++++++
6 files changed, 37 insertions(+), 7 deletions(-)
New commits:
commit 020c16333fea42c60108dcc475e7330fde7678a1
Author: Mark Reynolds <mreynolds(a)redhat.com>
Date: Tue Jan 21 17:05:59 2014 -0500
Ticket 47638 - Overflow in nsslapd-disk-monitoring-threshold on 32bit platform
Bug Description: On 32bit platforms 3000000000 overflows when retrieving the value
from the dse. The value was internally processed correctly, but
the value returned to the client was incorrect.
Fix Description: Created a new CONFIG_LONG_LONG config value type, and the
associated
slapi_entry_attr_set_* function.
https://fedorahosted.org/389/ticket/47638
Reviewed by: rmeggins(Thanks!)
diff --git a/ldap/servers/slapd/daemon.c b/ldap/servers/slapd/daemon.c
index 772f2a4..7594d53 100644
--- a/ldap/servers/slapd/daemon.c
+++ b/ldap/servers/slapd/daemon.c
@@ -704,7 +704,7 @@ disk_monitoring_thread(void *nothing)
char *dirstr = NULL;
PRUint64 previous_mark = 0;
PRUint64 disk_space = 0;
- PRUint64 threshold = 0;
+ PRInt64 threshold = 0;
PRUint64 halfway = 0;
time_t start = 0;
time_t now = 0;
diff --git a/ldap/servers/slapd/entry.c b/ldap/servers/slapd/entry.c
index cac02d5..d6e614f 100644
--- a/ldap/servers/slapd/entry.c
+++ b/ldap/servers/slapd/entry.c
@@ -3065,6 +3065,20 @@ slapi_entry_attr_set_long( Slapi_Entry* e, const char *type, long
l)
}
void
+slapi_entry_attr_set_longlong( Slapi_Entry* e, const char *type, long long l)
+{
+ char value[20];
+ struct berval bv;
+ struct berval *bvals[2];
+ bvals[0] = &bv;
+ bvals[1] = NULL;
+ sprintf(value,"%lld",l);
+ bv.bv_val = value;
+ bv.bv_len = strlen( value );
+ slapi_entry_attr_replace( e, type, bvals );
+}
+
+void
slapi_entry_attr_set_ulong( Slapi_Entry* e, const char *type, unsigned long l)
{
char value[16];
diff --git a/ldap/servers/slapd/libglobs.c b/ldap/servers/slapd/libglobs.c
index 195c430..93e49c3 100644
--- a/ldap/servers/slapd/libglobs.c
+++ b/ldap/servers/slapd/libglobs.c
@@ -105,6 +105,7 @@ typedef int (*LogSetFunc)(const char *attrname, char *value, int
whichlog,
typedef enum {
CONFIG_INT, /* maps to int */
CONFIG_LONG, /* maps to long */
+ CONFIG_LONG_LONG, /* maps to a long long (PRInt64) */
CONFIG_STRING, /* maps to char* */
CONFIG_CHARRAY, /* maps to char** */
CONFIG_ON_OFF, /* maps 0/1 to "off"/"on" */
@@ -1008,7 +1009,7 @@ static struct config_get_and_set {
{CONFIG_DISK_THRESHOLD, config_set_disk_threshold,
NULL, 0,
(void**)&global_slapdFrontendConfig.disk_threshold,
- CONFIG_LONG, (ConfigGetFunc)config_get_disk_threshold,
+ CONFIG_LONG_LONG, (ConfigGetFunc)config_get_disk_threshold,
DEFAULT_DISK_THRESHOLD},
{CONFIG_DISK_GRACE_PERIOD, config_set_disk_grace_period,
NULL, 0,
@@ -4388,10 +4389,10 @@ config_get_disk_grace_period(){
return retVal;
}
-PRUint64
+PRInt64
config_get_disk_threshold(){
slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- long retVal;
+ PRInt64 retVal;
CFG_LOCK_READ(slapdFrontendConfig);
retVal = slapdFrontendConfig->disk_threshold;
@@ -7256,7 +7257,12 @@ config_set_value(
else
slapi_entry_attr_set_charptr(e, cgas->attr_name, "");
break;
-
+ case CONFIG_LONG_LONG:
+ if (value)
+ slapi_entry_attr_set_longlong(e, cgas->attr_name, *((long long*)value));
+ else
+ slapi_entry_attr_set_charptr(e, cgas->attr_name, "");
+ break;
case CONFIG_STRING:
slapi_entry_attr_set_charptr(e, cgas->attr_name,
(value && *((char **)value)) ?
diff --git a/ldap/servers/slapd/proto-slap.h b/ldap/servers/slapd/proto-slap.h
index 358e103..9f77146 100644
--- a/ldap/servers/slapd/proto-slap.h
+++ b/ldap/servers/slapd/proto-slap.h
@@ -552,7 +552,7 @@ void config_set_accesslog_enabled(int value);
void config_set_auditlog_enabled(int value);
int config_get_accesslog_logging_enabled();
int config_get_disk_monitoring();
-PRUint64 config_get_disk_threshold();
+PRInt64 config_get_disk_threshold();
int config_get_disk_grace_period();
int config_get_disk_logging_critical();
int config_get_ndn_cache_count();
diff --git a/ldap/servers/slapd/slap.h b/ldap/servers/slapd/slap.h
index 710da22..6ef0916 100644
--- a/ldap/servers/slapd/slap.h
+++ b/ldap/servers/slapd/slap.h
@@ -2375,7 +2375,7 @@ typedef struct _slapdFrontendConfig {
/* disk monitoring */
slapi_onoff_t disk_monitoring;
- PRUint64 disk_threshold;
+ PRInt64 disk_threshold;
int disk_grace_period;
slapi_onoff_t disk_logging_critical;
diff --git a/ldap/servers/slapd/slapi-plugin.h b/ldap/servers/slapd/slapi-plugin.h
index cfac7c6..a4682b5 100644
--- a/ldap/servers/slapd/slapi-plugin.h
+++ b/ldap/servers/slapd/slapi-plugin.h
@@ -1934,6 +1934,16 @@ void slapi_entry_attr_set_uint( Slapi_Entry* e, const char *type,
unsigned int l
void slapi_entry_attr_set_long(Slapi_Entry* e, const char *type, long l);
/**
+ * Replaces the value or values of an attribute in an entry with a specified long long
+ * data type value.
+ *
+ * \param e Entry in which you want to set the value.
+ * \param type Attribute type in which you want to set the value.
+ * \param l Long Long integer value that you want to assign to the attribute.
+ */
+void slapi_entry_attr_set_longlong( Slapi_Entry* e, const char *type, long long l);
+
+/**
* Replaces the value or values of an attribute in an entry with a specified unsigned
* long data type value.
*