|
|
dc8c34 |
From fe06e62406826e17a190890c6818015085569243 Mon Sep 17 00:00:00 2001
|
|
|
dc8c34 |
From: Mark Reynolds <mreynolds@redhat.com>
|
|
|
dc8c34 |
Date: Tue, 21 Jan 2014 17:05:59 -0500
|
|
|
dc8c34 |
Subject: [PATCH 158/225] Ticket 47638 - Overflow in
|
|
|
dc8c34 |
nsslapd-disk-monitoring-threshold on 32bit platform
|
|
|
dc8c34 |
|
|
|
dc8c34 |
Bug Description: On 32bit platforms 3000000000 overflows when retrieving the value
|
|
|
dc8c34 |
from the dse. The value was internally processed correctly, but
|
|
|
dc8c34 |
the value returned to the client was incorrect.
|
|
|
dc8c34 |
|
|
|
dc8c34 |
Fix Description: Created a new CONFIG_LONG_LONG config value type, and the associated
|
|
|
dc8c34 |
slapi_entry_attr_set_* function.
|
|
|
dc8c34 |
|
|
|
dc8c34 |
https://fedorahosted.org/389/ticket/47638
|
|
|
dc8c34 |
|
|
|
dc8c34 |
Reviewed by: rmeggins(Thanks!)
|
|
|
dc8c34 |
(cherry picked from commit 75e760789f5b3fe03d5ee9e2f6433e7fb9a045f8)
|
|
|
dc8c34 |
---
|
|
|
dc8c34 |
ldap/servers/slapd/daemon.c | 2 +-
|
|
|
dc8c34 |
ldap/servers/slapd/entry.c | 14 ++++++++++++++
|
|
|
dc8c34 |
ldap/servers/slapd/libglobs.c | 16 ++++++++++++----
|
|
|
dc8c34 |
ldap/servers/slapd/proto-slap.h | 2 +-
|
|
|
dc8c34 |
ldap/servers/slapd/slap.h | 2 +-
|
|
|
dc8c34 |
ldap/servers/slapd/slapi-plugin.h | 10 ++++++++++
|
|
|
dc8c34 |
6 files changed, 39 insertions(+), 7 deletions(-)
|
|
|
dc8c34 |
|
|
|
dc8c34 |
diff --git a/ldap/servers/slapd/daemon.c b/ldap/servers/slapd/daemon.c
|
|
|
dc8c34 |
index 524a6aa..18c0988 100644
|
|
|
dc8c34 |
--- a/ldap/servers/slapd/daemon.c
|
|
|
dc8c34 |
+++ b/ldap/servers/slapd/daemon.c
|
|
|
dc8c34 |
@@ -702,7 +702,7 @@ disk_monitoring_thread(void *nothing)
|
|
|
dc8c34 |
char *dirstr = NULL;
|
|
|
dc8c34 |
PRUint64 previous_mark = 0;
|
|
|
dc8c34 |
PRUint64 disk_space = 0;
|
|
|
dc8c34 |
- PRUint64 threshold = 0;
|
|
|
dc8c34 |
+ PRInt64 threshold = 0;
|
|
|
dc8c34 |
PRUint64 halfway = 0;
|
|
|
dc8c34 |
time_t start = 0;
|
|
|
dc8c34 |
time_t now = 0;
|
|
|
dc8c34 |
diff --git a/ldap/servers/slapd/entry.c b/ldap/servers/slapd/entry.c
|
|
|
dc8c34 |
index d7df631..d47e0f6 100644
|
|
|
dc8c34 |
--- a/ldap/servers/slapd/entry.c
|
|
|
dc8c34 |
+++ b/ldap/servers/slapd/entry.c
|
|
|
dc8c34 |
@@ -2915,6 +2915,20 @@ slapi_entry_attr_set_long( Slapi_Entry* e, const char *type, long l)
|
|
|
dc8c34 |
}
|
|
|
dc8c34 |
|
|
|
dc8c34 |
void
|
|
|
dc8c34 |
+slapi_entry_attr_set_longlong( Slapi_Entry* e, const char *type, long long l)
|
|
|
dc8c34 |
+{
|
|
|
dc8c34 |
+ char value[20];
|
|
|
dc8c34 |
+ struct berval bv;
|
|
|
dc8c34 |
+ struct berval *bvals[2];
|
|
|
dc8c34 |
+ bvals[0] = &bv;
|
|
|
dc8c34 |
+ bvals[1] = NULL;
|
|
|
dc8c34 |
+ sprintf(value,"%lld",l);
|
|
|
dc8c34 |
+ bv.bv_val = value;
|
|
|
dc8c34 |
+ bv.bv_len = strlen( value );
|
|
|
dc8c34 |
+ slapi_entry_attr_replace( e, type, bvals );
|
|
|
dc8c34 |
+}
|
|
|
dc8c34 |
+
|
|
|
dc8c34 |
+void
|
|
|
dc8c34 |
slapi_entry_attr_set_ulong( Slapi_Entry* e, const char *type, unsigned long l)
|
|
|
dc8c34 |
{
|
|
|
dc8c34 |
char value[16];
|
|
|
dc8c34 |
diff --git a/ldap/servers/slapd/libglobs.c b/ldap/servers/slapd/libglobs.c
|
|
|
dc8c34 |
index 0fc9022..8352fc7 100644
|
|
|
dc8c34 |
--- a/ldap/servers/slapd/libglobs.c
|
|
|
dc8c34 |
+++ b/ldap/servers/slapd/libglobs.c
|
|
|
dc8c34 |
@@ -85,6 +85,7 @@
|
|
|
dc8c34 |
#define REMOVE_CHANGELOG_CMD "remove"
|
|
|
dc8c34 |
#define DEFAULT_SASL_MAXBUFSIZE "65536"
|
|
|
dc8c34 |
#define SLAPD_DEFAULT_SASL_MAXBUFSIZE 65536
|
|
|
dc8c34 |
+#define DEFAULT_DISK_THRESHOLD "2097152"
|
|
|
dc8c34 |
|
|
|
dc8c34 |
/* On UNIX, there's only one copy of slapd_ldap_debug */
|
|
|
dc8c34 |
/* On NT, each module keeps its own module_ldap_debug, which */
|
|
|
dc8c34 |
@@ -107,6 +108,7 @@ typedef int (*LogSetFunc)(const char *attrname, char *value, int whichlog,
|
|
|
dc8c34 |
typedef enum {
|
|
|
dc8c34 |
CONFIG_INT, /* maps to int */
|
|
|
dc8c34 |
CONFIG_LONG, /* maps to long */
|
|
|
dc8c34 |
+ CONFIG_LONG_LONG, /* maps to a long long (PRInt64) */
|
|
|
dc8c34 |
CONFIG_STRING, /* maps to char* */
|
|
|
dc8c34 |
CONFIG_CHARRAY, /* maps to char** */
|
|
|
dc8c34 |
CONFIG_ON_OFF, /* maps 0/1 to "off"/"on" */
|
|
|
dc8c34 |
@@ -680,7 +682,8 @@ static struct config_get_and_set {
|
|
|
dc8c34 |
{CONFIG_DISK_THRESHOLD, config_set_disk_threshold,
|
|
|
dc8c34 |
NULL, 0,
|
|
|
dc8c34 |
(void**)&global_slapdFrontendConfig.disk_threshold,
|
|
|
dc8c34 |
- CONFIG_LONG, (ConfigGetFunc)config_get_disk_threshold},
|
|
|
dc8c34 |
+ CONFIG_LONG_LONG, (ConfigGetFunc)config_get_disk_threshold,
|
|
|
dc8c34 |
+ DEFAULT_DISK_THRESHOLD},
|
|
|
dc8c34 |
{CONFIG_DISK_GRACE_PERIOD, config_set_disk_grace_period,
|
|
|
dc8c34 |
NULL, 0,
|
|
|
dc8c34 |
(void**)&global_slapdFrontendConfig.disk_grace_period,
|
|
|
dc8c34 |
@@ -3804,10 +3807,10 @@ config_get_disk_grace_period(){
|
|
|
dc8c34 |
return retVal;
|
|
|
dc8c34 |
}
|
|
|
dc8c34 |
|
|
|
dc8c34 |
-PRUint64
|
|
|
dc8c34 |
+PRInt64
|
|
|
dc8c34 |
config_get_disk_threshold(){
|
|
|
dc8c34 |
slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
|
|
|
dc8c34 |
- long retVal;
|
|
|
dc8c34 |
+ PRInt64 retVal;
|
|
|
dc8c34 |
|
|
|
dc8c34 |
CFG_LOCK_READ(slapdFrontendConfig);
|
|
|
dc8c34 |
retVal = slapdFrontendConfig->disk_threshold;
|
|
|
dc8c34 |
@@ -6357,7 +6360,12 @@ config_set_value(
|
|
|
dc8c34 |
else
|
|
|
dc8c34 |
slapi_entry_attr_set_charptr(e, cgas->attr_name, "");
|
|
|
dc8c34 |
break;
|
|
|
dc8c34 |
-
|
|
|
dc8c34 |
+ case CONFIG_LONG_LONG:
|
|
|
dc8c34 |
+ if (value)
|
|
|
dc8c34 |
+ slapi_entry_attr_set_longlong(e, cgas->attr_name, *((long long*)value));
|
|
|
dc8c34 |
+ else
|
|
|
dc8c34 |
+ slapi_entry_attr_set_charptr(e, cgas->attr_name, "");
|
|
|
dc8c34 |
+ break;
|
|
|
dc8c34 |
case CONFIG_STRING:
|
|
|
dc8c34 |
slapi_entry_attr_set_charptr(e, cgas->attr_name,
|
|
|
dc8c34 |
(value && *((char **)value)) ?
|
|
|
dc8c34 |
diff --git a/ldap/servers/slapd/proto-slap.h b/ldap/servers/slapd/proto-slap.h
|
|
|
dc8c34 |
index 233dc20..71a912e 100644
|
|
|
dc8c34 |
--- a/ldap/servers/slapd/proto-slap.h
|
|
|
dc8c34 |
+++ b/ldap/servers/slapd/proto-slap.h
|
|
|
dc8c34 |
@@ -545,7 +545,7 @@ void config_set_accesslog_enabled(int value);
|
|
|
dc8c34 |
void config_set_auditlog_enabled(int value);
|
|
|
dc8c34 |
int config_get_accesslog_logging_enabled();
|
|
|
dc8c34 |
int config_get_disk_monitoring();
|
|
|
dc8c34 |
-PRUint64 config_get_disk_threshold();
|
|
|
dc8c34 |
+PRInt64 config_get_disk_threshold();
|
|
|
dc8c34 |
int config_get_disk_grace_period();
|
|
|
dc8c34 |
int config_get_disk_logging_critical();
|
|
|
dc8c34 |
int config_get_sasl_maxbufsize();
|
|
|
dc8c34 |
diff --git a/ldap/servers/slapd/slap.h b/ldap/servers/slapd/slap.h
|
|
|
dc8c34 |
index 4724f27..5394455 100644
|
|
|
dc8c34 |
--- a/ldap/servers/slapd/slap.h
|
|
|
dc8c34 |
+++ b/ldap/servers/slapd/slap.h
|
|
|
dc8c34 |
@@ -2248,7 +2248,7 @@ typedef struct _slapdFrontendConfig {
|
|
|
dc8c34 |
|
|
|
dc8c34 |
/* disk monitoring */
|
|
|
dc8c34 |
int disk_monitoring;
|
|
|
dc8c34 |
- PRUint64 disk_threshold;
|
|
|
dc8c34 |
+ PRInt64 disk_threshold;
|
|
|
dc8c34 |
int disk_grace_period;
|
|
|
dc8c34 |
int disk_logging_critical;
|
|
|
dc8c34 |
int ignore_time_skew;
|
|
|
dc8c34 |
diff --git a/ldap/servers/slapd/slapi-plugin.h b/ldap/servers/slapd/slapi-plugin.h
|
|
|
dc8c34 |
index 58feaf3..a23b641 100644
|
|
|
dc8c34 |
--- a/ldap/servers/slapd/slapi-plugin.h
|
|
|
dc8c34 |
+++ b/ldap/servers/slapd/slapi-plugin.h
|
|
|
dc8c34 |
@@ -1784,6 +1784,16 @@ void slapi_entry_attr_set_uint( Slapi_Entry* e, const char *type, unsigned int l
|
|
|
dc8c34 |
void slapi_entry_attr_set_long(Slapi_Entry* e, const char *type, long l);
|
|
|
dc8c34 |
|
|
|
dc8c34 |
/**
|
|
|
dc8c34 |
+ * Replaces the value or values of an attribute in an entry with a specified long long
|
|
|
dc8c34 |
+ * data type value.
|
|
|
dc8c34 |
+ *
|
|
|
dc8c34 |
+ * \param e Entry in which you want to set the value.
|
|
|
dc8c34 |
+ * \param type Attribute type in which you want to set the value.
|
|
|
dc8c34 |
+ * \param l Long Long integer value that you want to assign to the attribute.
|
|
|
dc8c34 |
+ */
|
|
|
dc8c34 |
+void slapi_entry_attr_set_longlong( Slapi_Entry* e, const char *type, long long l);
|
|
|
dc8c34 |
+
|
|
|
dc8c34 |
+/**
|
|
|
dc8c34 |
* Replaces the value or values of an attribute in an entry with a specified unsigned
|
|
|
dc8c34 |
* long data type value.
|
|
|
dc8c34 |
*
|
|
|
dc8c34 |
--
|
|
|
dc8c34 |
1.8.1.4
|
|
|
dc8c34 |
|