Ticket was cloned from Red Hat Bugzilla (product Red Hat Enterprise Linux 6): Bug 982325
Description of problem: When nsslapd-disk-monitoring-threshold is set too high, it overflows to negative numbers. Version-Release number of selected component (if applicable): 389-ds-base-1.2.11.15-16.el6_4.x86_64 How reproducible: always Steps to Reproduce: 1. ldapmodify -h localhost -p 389 -D "cn=directory manager" -w Secret123 <<EOF dn: cn=config changetype: modify replace: nsslapd-disk-monitoring-threshold nsslapd-disk-monitoring-threshold: 3000000000 EOF 2. ldapsearch -h localhost -p 22139 -D "cn=directory manager" -w Secret123 -b "cn=config" -LLL -s base nsslapd-disk-monitoring-threshold dn: cn=config nsslapd-disk-monitoring-threshold: -1294967296 Actual results: nsslapd-disk-monitoring-threshold is set to -1294967296 instead of 3000000000 Expected results: Value should be refused if too high. Additional info:
On 32-bit platforms, long is 32 bits (ILP32), but on 64-bit platforms it is 64 bits (LP64). Since this is a value specific to the file system, which can be terabytes on 32-bit systems, you might want to use an explict 64-bit type to hold the value e.g. PRUint64
Replying to [comment:4 rmeggins]:
Revised patch attached...
Instead of ... 1677 1678 threshold = strtol(value, &endp, 10); strtoll would server better? long long int strtoll(const char nptr, char *endptr, int base);
In order to print a PRUint64 value using LDAPDebug, slapi_log_error, or any of the PR formatting functions, you have to use NSPRIu64 instead of "llu" and NSPRI64 instead of "ll" - for example:
{{{ LDAPDebug(LDAP_DEBUG_ANY, "Disk space on (%s) is too far below the threshold(%" NSPRIu64 " bytes). " }}} to use NSPRI64 do "value is %" NSPRI64 "d" - that is - NSPRIu64 includes the "u" unsigned specifier but NSPRI64 does not include the "d" specifier
Replying to [comment:7 rmeggins]:
In order to print a PRUint64 value using LDAPDebug, slapi_log_error, or any of the PR formatting functions, you have to use NSPRIu64 instead of "llu" and NSPRI64 instead of "ll" - for example: {{{ LDAPDebug(LDAP_DEBUG_ANY, "Disk space on (%s) is too far below the threshold(%" NSPRIu64 " bytes). " }}} to use NSPRI64 do "value is %" NSPRI64 "d" - that is - NSPRIu64 includes the "u" unsigned specifier but NSPRI64 does not include the "d" specifier
I'll change it, but the current code appears to work fine. It prints (1000000000000000000) correctly.
Replying to [comment:8 mreynolds]:
Replying to [comment:7 rmeggins]: In order to print a PRUint64 value using LDAPDebug, slapi_log_error, or any of the PR formatting functions, you have to use NSPRIu64 instead of "llu" and NSPRI64 instead of "ll" - for example: {{{ LDAPDebug(LDAP_DEBUG_ANY, "Disk space on (%s) is too far below the threshold(%" NSPRIu64 " bytes). " }}} to use NSPRI64 do "value is %" NSPRI64 "d" - that is - NSPRIu64 includes the "u" unsigned specifier but NSPRI64 does not include the "d" specifier I'll change it, but the current code appears to work fine. It prints (1000000000000000000) correctly.
Yeah, it works because NSPRIu64 is "llu"
Revision #2 0001-Ticket-47427-Overflow-in-nsslapd-disk-monitoring-thr.patch
Replying to [comment:9 rmeggins]:
Replying to [comment:8 mreynolds]: Replying to [comment:7 rmeggins]: In order to print a PRUint64 value using LDAPDebug, slapi_log_error, or any of the PR formatting functions, you have to use NSPRIu64 instead of "llu" and NSPRI64 instead of "ll" - for example: {{{ LDAPDebug(LDAP_DEBUG_ANY, "Disk space on (%s) is too far below the threshold(%" NSPRIu64 " bytes). " }}} to use NSPRI64 do "value is %" NSPRI64 "d" - that is - NSPRIu64 includes the "u" unsigned specifier but NSPRI64 does not include the "d" specifier I'll change it, but the current code appears to work fine. It prints (1000000000000000000) correctly. Yeah, it works because NSPRIu64 is "llu"
New patch attached...
ack
git merge ticket47427 Updating df93b03..6a0ed40 Fast-forward ldap/servers/slapd/daemon.c | 48 +++++++++++++++++++------------------- ldap/servers/slapd/libglobs.c | 12 +++++---- ldap/servers/slapd/proto-slap.h | 2 +- ldap/servers/slapd/slap.h | 2 +- 4 files changed, 33 insertions(+), 31 deletions(-)
git push origin master Counting objects: 17, done. Delta compression using up to 4 threads. Compressing objects: 100% (9/9), done. Writing objects: 100% (9/9), 1.28 KiB, done. Total 9 (delta 7), reused 0 (delta 0) To ssh://git.fedorahosted.org/git/389/ds.git df93b03..6a0ed40 master -> master
commit 6a0ed40b25a6dd4aaf3774a70199e8842499b42d
1.3.1
ed26da0..aee7b9d 389-ds-base-1.3.1 -> 389-ds-base-1.3.1
1.3.0
commit 3f7ca8b349719b0e6eb06071c4ede3e6271ae6dc commit e1eb377a2792a40f8d9b9933daa2d475d8544065 b18ee0b..3f7ca8b 389-ds-base-1.3.0 -> 389-ds-base-1.3.0
1.2.11
6e0a8ef..8b95375 389-ds-base-1.2.11 -> 389-ds-base-1.2.11 commit 8b95375701e6258a8a140c6e8078d2eb83159170
8b95375..52a0cc5 389-ds-base-1.2.11 -> 389-ds-base-1.2.11 commit 52a0cc593d0b6d018f3e17afdadcec737679f175 Author: Rich Megginson rmeggins@redhat.com Date: Thu Jul 11 10:58:07 2013 -0600 a71ea8c..b95142f 389-ds-base-1.3.0 -> 389-ds-base-1.3.0 commit b95142f08de7e3b7f66a395640709b80e7735bfd Author: Rich Megginson rmeggins@redhat.com Date: Thu Jul 11 10:58:07 2013 -0600 d9448c0..1b7135c 389-ds-base-1.3.1 -> 389-ds-base-1.3.1 commit 1b7135cc79114a41be147d6bac7f4353207623f1 Author: Rich Megginson rmeggins@redhat.com Date: Thu Jul 11 10:58:07 2013 -0600 fe0491c..5724e02 master -> master commit 5724e02c7f30ef1130764c79b30edd04954663a7 Author: Rich Megginson rmeggins@redhat.com Date: Thu Jul 11 10:58:07 2013 -0600
One line fix for casting issue 0001-Ticket-47427-Overflow-in-nsslapd-disk-monitoring-thr.2.patch
git merge ticket47427 Updating c94da99..90c04c0 Fast-forward ldap/servers/slapd/libglobs.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
git push origin master
c94da99..90c04c0 master -> master
commit 90c04c096876447ed3c1be0356fc346d3e492dc2
ac968a0..df0eb3a 389-ds-base-1.3.1 -> 389-ds-base-1.3.1
a94a75e..dd74bed 389-ds-base-1.3.0 -> 389-ds-base-1.3.0
f54e44c..23a6383 389-ds-base-1.2.11 -> 389-ds-base-1.2.11 commit 23a6383357990ea8f17fec9af155313d0a186af6
Revised the 1.2.11 commit(typo in libglobs)
23a6383..5a0d74a 389-ds-base-1.2.11 -> 389-ds-base-1.2.11
commit 5a0d74ab8030233bcde9aa787ba7a2929a75e267
Use signed int for parsing 0001-Ticket-47427-Overflow-in-nsslapd-disk-monitoring-thr.3.patch
git merge diskmon Updating 6bd78b3..0b30980 Fast-forward ldap/servers/slapd/libglobs.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
git push origin master Counting objects: 11, done. Delta compression using up to 4 threads. Compressing objects: 100% (6/6), done. Writing objects: 100% (6/6), 745 bytes, done. Total 6 (delta 4), reused 0 (delta 0) To ssh://git.fedorahosted.org/git/389/ds.git 6bd78b3..0b30980 master -> master
commit 0b30980695509347d8f883ac4405fa727041269f
8ea067b..84e0f3f 389-ds-base-1.3.1 -> 389-ds-base-1.3.1
93bde65..b74a5d1 389-ds-base-1.3.0 -> 389-ds-base-1.3.0
66fbebc..5bf8591 389-ds-base-1.2.11 -> 389-ds-base-1.2.11
use %lld for LONG_MAX instead of %ld in PR_snprintf 0001-Ticket-47427-Overflow-in-nsslapd-disk-monitoring-thr.4.patch
5bf8591..874f40e 389-ds-base-1.2.11 -> 389-ds-base-1.2.11 commit 874f40e7e775b7f71b50bd5c775da45d3f7dc888 Author: Rich Megginson rmeggins@redhat.com Date: Fri Jul 26 08:36:29 2013 -0600 b74a5d1..b8c921f 389-ds-base-1.3.0 -> 389-ds-base-1.3.0 b74a5d1..b8c921f 389-ds-base-1.3.0 -> 389-ds-base-1.3.0 commit b8c921f201929ec15974f2ccbe36af5caf74c74c Author: Rich Megginson rmeggins@redhat.com Date: Fri Jul 26 08:36:29 2013 -0600 84e0f3f..0b5fede 389-ds-base-1.3.1 -> 389-ds-base-1.3.1 commit 0b5fede023836b8b41a31c0106775767f306d21d Author: Rich Megginson rmeggins@redhat.com 0b30980..5df006b master -> master commit 5df006bd765163279f14cfbb0a136c15c69bed5b Author: Rich Megginson rmeggins@redhat.com Date: Fri Jul 26 08:36:29 2013 -0600
Metadata Update from @mreynolds: - Issue assigned to mreynolds - Issue set to the milestone: 1.2.11.22
389-ds-base is moving from Pagure to Github. This means that new issues and pull requests will be accepted only in 389-ds-base's github repository.
This issue has been cloned to Github and is available here: - https://github.com/389ds/389-ds-base/issues/764
If you want to receive further updates on the issue, please navigate to the github issue and click on subscribe button.
subscribe
Thank you for understanding. We apologize for all inconvenience.
Metadata Update from @spichugi: - Issue close_status updated to: wontfix (was: Fixed)