#47427 Overflow in nsslapd-disk-monitoring-threshold
Closed: wontfix None Opened 10 years ago by nkinder.

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]:

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

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"

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...

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 6a0ed40

1.3.1

ed26da0..aee7b9d 389-ds-base-1.3.1 -> 389-ds-base-1.3.1

1.3.0

commit 3f7ca8b
commit e1eb377
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 8b95375

8b95375..52a0cc5 389-ds-base-1.2.11 -> 389-ds-base-1.2.11
commit 52a0cc5
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 b95142f
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 1b7135c
Author: Rich Megginson rmeggins@redhat.com
Date: Thu Jul 11 10:58:07 2013 -0600
fe0491c..5724e02 master -> master
commit 5724e02
Author: Rich Megginson rmeggins@redhat.com
Date: Thu Jul 11 10:58:07 2013 -0600

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 90c04c0

1.3.1

ac968a0..df0eb3a 389-ds-base-1.3.1 -> 389-ds-base-1.3.1

1.3.0

a94a75e..dd74bed 389-ds-base-1.3.0 -> 389-ds-base-1.3.0

1.2.11

f54e44c..23a6383 389-ds-base-1.2.11 -> 389-ds-base-1.2.11
commit 23a6383

Revised the 1.2.11 commit(typo in libglobs)

23a6383..5a0d74a 389-ds-base-1.2.11 -> 389-ds-base-1.2.11

commit 5a0d74a

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 0b30980

1.3.1

8ea067b..84e0f3f 389-ds-base-1.3.1 -> 389-ds-base-1.3.1

1.3.0

93bde65..b74a5d1 389-ds-base-1.3.0 -> 389-ds-base-1.3.0

1.2.11

66fbebc..5bf8591 389-ds-base-1.2.11 -> 389-ds-base-1.2.11

5bf8591..874f40e 389-ds-base-1.2.11 -> 389-ds-base-1.2.11
commit 874f40e
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 b8c921f
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 0b5fede
Author: Rich Megginson rmeggins@redhat.com
0b30980..5df006b master -> master
commit 5df006b
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

7 years ago

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.

Thank you for understanding. We apologize for all inconvenience.

Metadata Update from @spichugi:
- Issue close_status updated to: wontfix (was: Fixed)

3 years ago

Login to comment on this ticket.

Metadata