|
|
dc8c34 |
From f71f0f4f8d07b09fab205bf4d1cbd9dbc59074fc Mon Sep 17 00:00:00 2001
|
|
|
dc8c34 |
From: Noriko Hosoi <nhosoi@redhat.com>
|
|
|
dc8c34 |
Date: Sun, 12 Feb 2017 17:26:46 -0800
|
|
|
dc8c34 |
Subject: [PATCH] Ticket #49121 - ns-slapd crashes in ldif_sput due to the
|
|
|
dc8c34 |
output buf size is less than the real size.
|
|
|
dc8c34 |
|
|
|
dc8c34 |
Description: There were missing pieces in the entry size calculation
|
|
|
dc8c34 |
when an attribute had no a_present_values nor a_deleted_values.
|
|
|
dc8c34 |
1) There was no chance to add the size of the attribute type name since
|
|
|
dc8c34 |
preceding entry2str_internal_size_valueset did not add any size if
|
|
|
dc8c34 |
the value was empty. The type name size is now explicitly added.
|
|
|
dc8c34 |
2) a_deletioncsn is added in entry2str_internal_put_attrlist by calling
|
|
|
dc8c34 |
valueset_add_string with empty value. The size was not included in
|
|
|
dc8c34 |
the allocated memory to store the entire entry as a string. Now the
|
|
|
dc8c34 |
size is added.
|
|
|
dc8c34 |
|
|
|
dc8c34 |
Adding CI test ticket49121_test.py.
|
|
|
dc8c34 |
|
|
|
dc8c34 |
https://pagure.io/389-ds-base/issue/49121
|
|
|
dc8c34 |
|
|
|
dc8c34 |
Reviewed by wibrown@redhat.com (Thank you, William!!)
|
|
|
dc8c34 |
|
|
|
dc8c34 |
(cherry picked from commit 543fe89edb0a6410a740a4fff738cace7bc57078)
|
|
|
dc8c34 |
---
|
|
|
dc8c34 |
dirsrvtests/tests/data/ticket49121/utf8str.txt | 1 +
|
|
|
dc8c34 |
dirsrvtests/tests/tickets/ticket49121_test.py | 211 +++++++++++++++++++++++++
|
|
|
dc8c34 |
ldap/servers/slapd/entry.c | 55 ++++---
|
|
|
dc8c34 |
3 files changed, 244 insertions(+), 23 deletions(-)
|
|
|
dc8c34 |
create mode 100644 dirsrvtests/tests/data/ticket49121/utf8str.txt
|
|
|
dc8c34 |
create mode 100644 dirsrvtests/tests/tickets/ticket49121_test.py
|
|
|
dc8c34 |
|
|
|
dc8c34 |
diff --git a/dirsrvtests/tests/data/ticket49121/utf8str.txt b/dirsrvtests/tests/data/ticket49121/utf8str.txt
|
|
|
dc8c34 |
new file mode 100644
|
|
|
dc8c34 |
index 0000000..0005c4e
|
|
|
dc8c34 |
--- /dev/null
|
|
|
dc8c34 |
+++ b/dirsrvtests/tests/data/ticket49121/utf8str.txt
|
|
|
dc8c34 |
@@ -0,0 +1 @@
|
|
|
dc8c34 |
+あいうえお
|
|
|
dc8c34 |
diff --git a/dirsrvtests/tests/tickets/ticket49121_test.py b/dirsrvtests/tests/tickets/ticket49121_test.py
|
|
|
dc8c34 |
new file mode 100644
|
|
|
dc8c34 |
index 0000000..6450297
|
|
|
dc8c34 |
--- /dev/null
|
|
|
dc8c34 |
+++ b/dirsrvtests/tests/tickets/ticket49121_test.py
|
|
|
dc8c34 |
@@ -0,0 +1,211 @@
|
|
|
dc8c34 |
+# --- BEGIN COPYRIGHT BLOCK ---
|
|
|
dc8c34 |
+# Copyright (C) 2017 Red Hat, Inc.
|
|
|
dc8c34 |
+# All rights reserved.
|
|
|
dc8c34 |
+#
|
|
|
dc8c34 |
+# License: GPL (version 3 or any later version).
|
|
|
dc8c34 |
+# See LICENSE for details.
|
|
|
dc8c34 |
+# --- END COPYRIGHT BLOCK ---
|
|
|
dc8c34 |
+#
|
|
|
dc8c34 |
+import pytest
|
|
|
dc8c34 |
+import sys
|
|
|
dc8c34 |
+import codecs
|
|
|
dc8c34 |
+from lib389.tasks import *
|
|
|
dc8c34 |
+from lib389.utils import *
|
|
|
dc8c34 |
+from lib389.topologies import topology_m2
|
|
|
dc8c34 |
+
|
|
|
dc8c34 |
+DEBUGGING = os.getenv('DEBUGGING', False)
|
|
|
dc8c34 |
+
|
|
|
dc8c34 |
+if DEBUGGING:
|
|
|
dc8c34 |
+ logging.getLogger(__name__).setLevel(logging.DEBUG)
|
|
|
dc8c34 |
+else:
|
|
|
dc8c34 |
+ logging.getLogger(__name__).setLevel(logging.INFO)
|
|
|
dc8c34 |
+log = logging.getLogger(__name__)
|
|
|
dc8c34 |
+
|
|
|
dc8c34 |
+
|
|
|
dc8c34 |
+def test_ticket49121(topology_m2):
|
|
|
dc8c34 |
+ """
|
|
|
dc8c34 |
+ Creating some users.
|
|
|
dc8c34 |
+ Deleting quite a number of attributes which may or may not be in the entry.
|
|
|
dc8c34 |
+ The attribute type names are to be long.
|
|
|
dc8c34 |
+ Under the conditions, it did not estimate the size of string format entry
|
|
|
dc8c34 |
+ shorter than the real size and caused the Invalid write / server crash.
|
|
|
dc8c34 |
+ """
|
|
|
dc8c34 |
+ reload(sys)
|
|
|
dc8c34 |
+ sys.setdefaultencoding('utf-8')
|
|
|
dc8c34 |
+ log.info('DefaultEncoding: %s' % sys.getdefaultencoding())
|
|
|
dc8c34 |
+
|
|
|
dc8c34 |
+ utf8file = os.path.join(topology_m2.ms["master1"].getDir(__file__, DATA_DIR), "ticket49121/utf8str.txt")
|
|
|
dc8c34 |
+ utf8obj = codecs.open(utf8file, 'r', 'utf-8')
|
|
|
dc8c34 |
+ utf8strorig = utf8obj.readline()
|
|
|
dc8c34 |
+ utf8str = utf8strorig.encode('utf-8').rstrip('\n')
|
|
|
dc8c34 |
+ utf8obj.close()
|
|
|
dc8c34 |
+ assert(utf8str)
|
|
|
dc8c34 |
+
|
|
|
dc8c34 |
+ # Get the sbin directory so we know where to replace 'ns-slapd'
|
|
|
dc8c34 |
+ sbin_dir = topology_m2.ms["master1"].get_sbin_dir()
|
|
|
dc8c34 |
+ log.info('sbin_dir: %s' % sbin_dir)
|
|
|
dc8c34 |
+
|
|
|
dc8c34 |
+ # stop M1 to do the next updates
|
|
|
dc8c34 |
+ topology_m2.ms["master1"].stop(30)
|
|
|
dc8c34 |
+ topology_m2.ms["master2"].stop(30)
|
|
|
dc8c34 |
+
|
|
|
dc8c34 |
+ # wait for the servers shutdown
|
|
|
dc8c34 |
+ time.sleep(5)
|
|
|
dc8c34 |
+
|
|
|
dc8c34 |
+ # Enable valgrind
|
|
|
dc8c34 |
+ if not topology_m2.ms["master1"].has_asan():
|
|
|
dc8c34 |
+ valgrind_enable(sbin_dir)
|
|
|
dc8c34 |
+
|
|
|
dc8c34 |
+ # start M1 to do the next updates
|
|
|
dc8c34 |
+ topology_m2.ms["master1"].start()
|
|
|
dc8c34 |
+ topology_m2.ms["master2"].start()
|
|
|
dc8c34 |
+
|
|
|
dc8c34 |
+ for idx in range(1, 10):
|
|
|
dc8c34 |
+ try:
|
|
|
dc8c34 |
+ USER_DN = 'CN=user%d,ou=People,%s' % (idx, DEFAULT_SUFFIX)
|
|
|
dc8c34 |
+ log.info('adding user %s...' % (USER_DN))
|
|
|
dc8c34 |
+ topology_m2.ms["master1"].add_s(Entry((USER_DN,
|
|
|
dc8c34 |
+ {'objectclass': 'top person extensibleObject'.split(' '),
|
|
|
dc8c34 |
+ 'cn': 'user%d' % idx,
|
|
|
dc8c34 |
+ 'sn': 'SN%d-%s' % (idx, utf8str)})))
|
|
|
dc8c34 |
+ except ldap.LDAPError as e:
|
|
|
dc8c34 |
+ log.fatal('Failed to add user (%s): error %s' % (USER_DN, e.message['desc']))
|
|
|
dc8c34 |
+ assert False
|
|
|
dc8c34 |
+
|
|
|
dc8c34 |
+ for i in range(1, 3):
|
|
|
dc8c34 |
+ time.sleep(3)
|
|
|
dc8c34 |
+ for idx in range(1, 10):
|
|
|
dc8c34 |
+ try:
|
|
|
dc8c34 |
+ USER_DN = 'CN=user%d,ou=People,%s' % (idx, DEFAULT_SUFFIX)
|
|
|
dc8c34 |
+ log.info('[%d] modify user %s - replacing attrs...' % (i, USER_DN))
|
|
|
dc8c34 |
+ topology_m2.ms["master1"].modify_s(
|
|
|
dc8c34 |
+ USER_DN, [(ldap.MOD_REPLACE, 'cn', 'user%d' % idx),
|
|
|
dc8c34 |
+ (ldap.MOD_REPLACE, 'ABCDEFGH_ID', ['239001ad-06dd-e011-80fa-c00000ad5174',
|
|
|
dc8c34 |
+ '240f0878-c552-e411-b0f3-000006040037']),
|
|
|
dc8c34 |
+ (ldap.MOD_REPLACE, 'attr1', 'NEW_ATTR'),
|
|
|
dc8c34 |
+ (ldap.MOD_REPLACE, 'attr20000000000000000000000000000000000000000', None),
|
|
|
dc8c34 |
+ (ldap.MOD_REPLACE, 'attr30000000000000000000000000000000000000000000000', None),
|
|
|
dc8c34 |
+ (ldap.MOD_REPLACE, 'attr40000000000000000000000000000', None),
|
|
|
dc8c34 |
+ (ldap.MOD_REPLACE, 'attr50000000000000000000000000000000000000', None),
|
|
|
dc8c34 |
+ (ldap.MOD_REPLACE, 'attr600000000000000000000000000000000000000000', None),
|
|
|
dc8c34 |
+ (ldap.MOD_REPLACE, 'attr7000000000000000000000000000000', None),
|
|
|
dc8c34 |
+ (ldap.MOD_REPLACE, 'attr8000000000000000000000000000000000', None),
|
|
|
dc8c34 |
+ (ldap.MOD_REPLACE, 'attr900000000000000000', None),
|
|
|
dc8c34 |
+ (ldap.MOD_REPLACE, 'attr1000000000000000000000', None),
|
|
|
dc8c34 |
+ (ldap.MOD_REPLACE, 'attr110000000000000', None),
|
|
|
dc8c34 |
+ (ldap.MOD_REPLACE, 'attr120000000000000', None),
|
|
|
dc8c34 |
+ (ldap.MOD_REPLACE, 'attr130000000000000000000000000000000000000000000000', None),
|
|
|
dc8c34 |
+ (ldap.MOD_REPLACE, 'attr140000000000000000000000000000', None),
|
|
|
dc8c34 |
+ (ldap.MOD_REPLACE, 'attr150000000000000000000000000000000000000000000000000000000000000', None),
|
|
|
dc8c34 |
+ (ldap.MOD_REPLACE, 'attr1600000000000000000000000000000000000000000', None),
|
|
|
dc8c34 |
+ (ldap.MOD_REPLACE, 'attr17000000000000000000000000000000', None),
|
|
|
dc8c34 |
+ (ldap.MOD_REPLACE, 'attr18000000000000000000000000000000000', None),
|
|
|
dc8c34 |
+ (ldap.MOD_REPLACE, 'attr1900000000000000000', None),
|
|
|
dc8c34 |
+ (ldap.MOD_REPLACE, 'attr2000000000000000000000', None),
|
|
|
dc8c34 |
+ (ldap.MOD_REPLACE, 'attr210000000000000000000000000000000000000000', None),
|
|
|
dc8c34 |
+ (ldap.MOD_REPLACE, 'attr220000000000000000000000000000000000000000', None),
|
|
|
dc8c34 |
+ (ldap.MOD_REPLACE, 'attr230000000000000000000000000000000000000000', None),
|
|
|
dc8c34 |
+ (ldap.MOD_REPLACE, 'attr240000000000000000000000000000000000000000', None),
|
|
|
dc8c34 |
+ (ldap.MOD_REPLACE, 'attr25000000000000000000000000000000', None),
|
|
|
dc8c34 |
+ (ldap.MOD_REPLACE, 'attr260000000000000000000000000000000000000000', None),
|
|
|
dc8c34 |
+ (ldap.MOD_REPLACE, 'attr270000000000000000000000000000000000000000000000000000000000000000000000', None),
|
|
|
dc8c34 |
+ (ldap.MOD_REPLACE, 'attr280000000000000000000000000000000000000000', None),
|
|
|
dc8c34 |
+ (ldap.MOD_REPLACE, 'attr29000000000000000000000000000000000000000000000000000000000', None),
|
|
|
dc8c34 |
+ (ldap.MOD_REPLACE, 'attr3000000000000000000000000', None),
|
|
|
dc8c34 |
+ (ldap.MOD_REPLACE, 'attr310000000000000000000000000000000000000000000000', None),
|
|
|
dc8c34 |
+ (ldap.MOD_REPLACE, 'attr320000000000000000000000000000000000000000000000', None),
|
|
|
dc8c34 |
+ (ldap.MOD_REPLACE, 'attr330000000000000000000000000000000000000000000000', None),
|
|
|
dc8c34 |
+ (ldap.MOD_REPLACE, 'attr340000000000000000000000000000000000000000000000', None),
|
|
|
dc8c34 |
+ (ldap.MOD_REPLACE, 'attr350000000000000000000000000000000000000000', None),
|
|
|
dc8c34 |
+ (ldap.MOD_REPLACE, 'attr360000000000000000000000000000000000000000000000', None),
|
|
|
dc8c34 |
+ (ldap.MOD_REPLACE, 'attr370000000000000000000000000000000000000000000000', None),
|
|
|
dc8c34 |
+ (ldap.MOD_REPLACE, 'attr380000000000000000000000000000000000000000000000', None),
|
|
|
dc8c34 |
+ (ldap.MOD_REPLACE, 'attr390000000000000000000000000000000000000000000000', None),
|
|
|
dc8c34 |
+ (ldap.MOD_REPLACE, 'attr4000000000000000000000000', None),
|
|
|
dc8c34 |
+ (ldap.MOD_REPLACE, 'attr410000000000000000000000000000', None),
|
|
|
dc8c34 |
+ (ldap.MOD_REPLACE, 'attr420000000000000000000000000000', None),
|
|
|
dc8c34 |
+ (ldap.MOD_REPLACE, 'attr430000000000000000000000000000', None),
|
|
|
dc8c34 |
+ (ldap.MOD_REPLACE, 'attr440000000000000000000000000000', None),
|
|
|
dc8c34 |
+ (ldap.MOD_REPLACE, 'attr4500000000000000000000000000000000000000', None),
|
|
|
dc8c34 |
+ (ldap.MOD_REPLACE, 'attr460000000000000000000000000000', None),
|
|
|
dc8c34 |
+ (ldap.MOD_REPLACE, 'attr470000000000000000000000000000000000000000000000000000000000', None),
|
|
|
dc8c34 |
+ (ldap.MOD_REPLACE, 'attr480000000000000000000000000000', None),
|
|
|
dc8c34 |
+ (ldap.MOD_REPLACE, 'attr49000000000000000000000000000000000000000000000', None),
|
|
|
dc8c34 |
+ (ldap.MOD_REPLACE, 'attr5000000000000000000000000', None),
|
|
|
dc8c34 |
+ (ldap.MOD_REPLACE, 'attr510000000000000', None),
|
|
|
dc8c34 |
+ (ldap.MOD_REPLACE, 'attr520000000000000', None),
|
|
|
dc8c34 |
+ (ldap.MOD_REPLACE, 'attr530000000000000', None),
|
|
|
dc8c34 |
+ (ldap.MOD_REPLACE, 'attr540000000000000', None),
|
|
|
dc8c34 |
+ (ldap.MOD_REPLACE, 'attr550000000000000000000000000000000000000', None),
|
|
|
dc8c34 |
+ (ldap.MOD_REPLACE, 'attr5600000000000000000000000000000000000000000', None),
|
|
|
dc8c34 |
+ (ldap.MOD_REPLACE, 'attr57000000000000000000000000000000', None),
|
|
|
dc8c34 |
+ (ldap.MOD_REPLACE, 'attr58000000000000000000000000000000000', None),
|
|
|
dc8c34 |
+ (ldap.MOD_REPLACE, 'attr5900000000000000000', None),
|
|
|
dc8c34 |
+ (ldap.MOD_REPLACE, 'attr6000000000000000000000000', None),
|
|
|
dc8c34 |
+ (ldap.MOD_REPLACE, 'attr6100000000000000000000000000000000000000000', None),
|
|
|
dc8c34 |
+ (ldap.MOD_REPLACE, 'attr6200000000000000000000000000000000000000000', None),
|
|
|
dc8c34 |
+ (ldap.MOD_REPLACE, 'attr6300000000000000000000000000000000000000000', None),
|
|
|
dc8c34 |
+ (ldap.MOD_REPLACE, 'attr6400000000000000000000000000000000000000000', None),
|
|
|
dc8c34 |
+ (ldap.MOD_REPLACE, 'attr65000000000000000000000000000000000000000000000000000000000000000000000000000000', None),
|
|
|
dc8c34 |
+ (ldap.MOD_REPLACE, 'attr6600000000000000000000000000000000000000000', None),
|
|
|
dc8c34 |
+ (ldap.MOD_REPLACE, 'attr6700000000000000000000000000000000000000000', None),
|
|
|
dc8c34 |
+ (ldap.MOD_REPLACE, 'attr6800000000000000000000000000000000000000000', None),
|
|
|
dc8c34 |
+ (ldap.MOD_REPLACE, 'attr690000000000000000000000000000000000000000000000000000000000', None),
|
|
|
dc8c34 |
+ (ldap.MOD_REPLACE, 'attr7000000000000000000000000', None),
|
|
|
dc8c34 |
+ (ldap.MOD_REPLACE, 'attr71000000000000000000000000000000', None),
|
|
|
dc8c34 |
+ (ldap.MOD_REPLACE, 'attr72000000000000000000000000000000', None),
|
|
|
dc8c34 |
+ (ldap.MOD_REPLACE, 'attr73000000000000000000000000000000', None),
|
|
|
dc8c34 |
+ (ldap.MOD_REPLACE, 'attr74000000000000000000000000000000', None),
|
|
|
dc8c34 |
+ (ldap.MOD_REPLACE, 'attr750000000000000000000000000000000000000000000', None),
|
|
|
dc8c34 |
+ (ldap.MOD_REPLACE, 'attr7600000000000000000000000000000000000000000', None),
|
|
|
dc8c34 |
+ (ldap.MOD_REPLACE, 'attr77000000000000000000000000000000', None),
|
|
|
dc8c34 |
+ (ldap.MOD_REPLACE, 'attr78000000000000000000000000000000000000000000000000000000000000000', None),
|
|
|
dc8c34 |
+ (ldap.MOD_REPLACE, 'attr79000000000000000000000000000000', None),
|
|
|
dc8c34 |
+ (ldap.MOD_REPLACE, 'attr800000000000000000000000000000000000000000000000', None),
|
|
|
dc8c34 |
+ (ldap.MOD_REPLACE, 'attr81000000000000000000000000000000000', None),
|
|
|
dc8c34 |
+ (ldap.MOD_REPLACE, 'attr82000000000000000000000000000000000', None),
|
|
|
dc8c34 |
+ (ldap.MOD_REPLACE, 'attr83000000000000000000000000000000000', None),
|
|
|
dc8c34 |
+ (ldap.MOD_REPLACE, 'attr84000000000000000000000000000000000', None),
|
|
|
dc8c34 |
+ (ldap.MOD_REPLACE, 'attr85000000000000000000000000000000000000000000000000000', None),
|
|
|
dc8c34 |
+ (ldap.MOD_REPLACE, 'attr8600000000000000000000000000000000000000000', None),
|
|
|
dc8c34 |
+ (ldap.MOD_REPLACE, 'attr87000000000000000000000000000000', None),
|
|
|
dc8c34 |
+ (ldap.MOD_REPLACE, 'attr88000000000000000000000000000000000', None),
|
|
|
dc8c34 |
+ (ldap.MOD_REPLACE, 'attr89000000000000000000000000000000000', None),
|
|
|
dc8c34 |
+ (ldap.MOD_REPLACE, 'attr9000000000000000000000000000000000000000000000000000', None)])
|
|
|
dc8c34 |
+ except ldap.LDAPError as e:
|
|
|
dc8c34 |
+ log.fatal('Failed to modify user - deleting attrs (%s): error %s' % (USER_DN, e.message['desc']))
|
|
|
dc8c34 |
+
|
|
|
dc8c34 |
+ if not topology_m2.ms["master1"].has_asan():
|
|
|
dc8c34 |
+ results_file = valgrind_get_results_file(topology_m2.ms["master1"])
|
|
|
dc8c34 |
+
|
|
|
dc8c34 |
+ # Stop master2
|
|
|
dc8c34 |
+ topology_m2.ms["master1"].stop(30)
|
|
|
dc8c34 |
+ topology_m2.ms["master2"].stop(30)
|
|
|
dc8c34 |
+
|
|
|
dc8c34 |
+ # Check for leak
|
|
|
dc8c34 |
+ if not topology_m2.ms["master1"].has_asan():
|
|
|
dc8c34 |
+ # Check for invalid read/write
|
|
|
dc8c34 |
+ if valgrind_check_file(results_file, VALGRIND_INVALID_STR):
|
|
|
dc8c34 |
+ log.info('Valgrind reported invalid!')
|
|
|
dc8c34 |
+ assert False
|
|
|
dc8c34 |
+ else:
|
|
|
dc8c34 |
+ log.info('Valgrind is happy!')
|
|
|
dc8c34 |
+
|
|
|
dc8c34 |
+ # Disable valgrind
|
|
|
dc8c34 |
+ if not topology_m2.ms["master1"].has_asan():
|
|
|
dc8c34 |
+ valgrind_disable(sbin_dir)
|
|
|
dc8c34 |
+
|
|
|
dc8c34 |
+ # start M1 to do the next updates
|
|
|
dc8c34 |
+ topology_m2.ms["master1"].start()
|
|
|
dc8c34 |
+ topology_m2.ms["master2"].start()
|
|
|
dc8c34 |
+
|
|
|
dc8c34 |
+ log.info('Testcase PASSED')
|
|
|
dc8c34 |
+ if DEBUGGING:
|
|
|
dc8c34 |
+ # Add debugging steps(if any)...
|
|
|
dc8c34 |
+ pass
|
|
|
dc8c34 |
+
|
|
|
dc8c34 |
+if __name__ == '__main__':
|
|
|
dc8c34 |
+ # Run isolated
|
|
|
dc8c34 |
+ # -s for DEBUG mode
|
|
|
dc8c34 |
+ CURRENT_FILE = os.path.realpath(__file__)
|
|
|
dc8c34 |
+ pytest.main("-s %s" % CURRENT_FILE)
|
|
|
dc8c34 |
diff --git a/ldap/servers/slapd/entry.c b/ldap/servers/slapd/entry.c
|
|
|
dc8c34 |
index 09671a4..a2fd44a 100644
|
|
|
dc8c34 |
--- a/ldap/servers/slapd/entry.c
|
|
|
dc8c34 |
+++ b/ldap/servers/slapd/entry.c
|
|
|
dc8c34 |
@@ -1436,7 +1436,8 @@ bail:
|
|
|
dc8c34 |
}
|
|
|
dc8c34 |
|
|
|
dc8c34 |
static size_t
|
|
|
dc8c34 |
-entry2str_internal_size_valueset( const char *attrtype, const Slapi_ValueSet *vs, int entry2str_ctrl, int attribute_state, int value_state )
|
|
|
dc8c34 |
+entry2str_internal_size_valueset( const Slapi_Attr *a, const char *attrtype, const Slapi_ValueSet *vs,
|
|
|
dc8c34 |
+ int entry2str_ctrl, int attribute_state, int value_state )
|
|
|
dc8c34 |
{
|
|
|
dc8c34 |
size_t elen= 0;
|
|
|
dc8c34 |
if(!valueset_isempty(vs))
|
|
|
dc8c34 |
@@ -1449,6 +1450,12 @@ entry2str_internal_size_valueset( const char *attrtype, const Slapi_ValueSet *vs
|
|
|
dc8c34 |
attribute_state, value_state );
|
|
|
dc8c34 |
}
|
|
|
dc8c34 |
}
|
|
|
dc8c34 |
+ if(entry2str_ctrl & SLAPI_DUMP_STATEINFO) {
|
|
|
dc8c34 |
+ /* ";adcsn-" + a->a_deletioncsn */
|
|
|
dc8c34 |
+ if ( a && a->a_deletioncsn ) {
|
|
|
dc8c34 |
+ elen += 1 + LDIF_CSNPREFIX_MAXLENGTH + CSN_STRSIZE;
|
|
|
dc8c34 |
+ }
|
|
|
dc8c34 |
+ }
|
|
|
dc8c34 |
return elen;
|
|
|
dc8c34 |
}
|
|
|
dc8c34 |
|
|
|
dc8c34 |
@@ -1465,30 +1472,34 @@ entry2str_internal_size_attrlist( const Slapi_Attr *attrlist, int entry2str_ctrl
|
|
|
dc8c34 |
continue;
|
|
|
dc8c34 |
|
|
|
dc8c34 |
/* Count the space required for the present and deleted values */
|
|
|
dc8c34 |
- elen+= entry2str_internal_size_valueset(a->a_type, &a->a_present_values,
|
|
|
dc8c34 |
- entry2str_ctrl, attribute_state,
|
|
|
dc8c34 |
- VALUE_PRESENT);
|
|
|
dc8c34 |
- if(entry2str_ctrl & SLAPI_DUMP_STATEINFO)
|
|
|
dc8c34 |
- {
|
|
|
dc8c34 |
- elen+= entry2str_internal_size_valueset(a->a_type, &a->a_deleted_values,
|
|
|
dc8c34 |
- entry2str_ctrl, attribute_state,
|
|
|
dc8c34 |
- VALUE_DELETED);
|
|
|
dc8c34 |
- /* ";adcsn-" + a->a_deletioncsn */
|
|
|
dc8c34 |
- if ( a->a_deletioncsn )
|
|
|
dc8c34 |
- {
|
|
|
dc8c34 |
- elen += 1 + LDIF_CSNPREFIX_MAXLENGTH + CSN_STRSIZE;
|
|
|
dc8c34 |
- }
|
|
|
dc8c34 |
- if ( valueset_isempty(&a->a_deleted_values)) {
|
|
|
dc8c34 |
+ elen += entry2str_internal_size_valueset(a, a->a_type, &a->a_present_values,
|
|
|
dc8c34 |
+ entry2str_ctrl, attribute_state, VALUE_PRESENT);
|
|
|
dc8c34 |
+ if (entry2str_ctrl & SLAPI_DUMP_STATEINFO) {
|
|
|
dc8c34 |
+ elen += entry2str_internal_size_valueset(a, a->a_type, &a->a_deleted_values,
|
|
|
dc8c34 |
+ entry2str_ctrl, attribute_state, VALUE_DELETED);
|
|
|
dc8c34 |
+ if (valueset_isempty(&a->a_deleted_values) && valueset_isempty(&a->a_present_values)) {
|
|
|
dc8c34 |
/* this means the entry is deleted and has no more attributes,
|
|
|
dc8c34 |
* when writing the attr to disk we would loose the AD-csn.
|
|
|
dc8c34 |
- * Add an empty value to the set of deleted values. This will
|
|
|
dc8c34 |
- * never be seen by any client. It will never be moved to the
|
|
|
dc8c34 |
+ * Add an empty value to the set of deleted values. This will
|
|
|
dc8c34 |
+ * never be seen by any client. It will never be moved to the
|
|
|
dc8c34 |
* present values and is only used to preserve the AD-csn
|
|
|
dc8c34 |
* We need to add the size for that.
|
|
|
dc8c34 |
*/
|
|
|
dc8c34 |
elen += 1 + LDIF_CSNPREFIX_MAXLENGTH + CSN_STRSIZE;
|
|
|
dc8c34 |
- /* need also space for ";deletedattribute;deleted" */
|
|
|
dc8c34 |
- elen += DELETED_ATTR_STRSIZE + DELETED_VALUE_STRSIZE;
|
|
|
dc8c34 |
+ /* need also space for ";deletedattribute;deleted" */
|
|
|
dc8c34 |
+ elen += DELETED_ATTR_STRSIZE + DELETED_VALUE_STRSIZE;
|
|
|
dc8c34 |
+ /*
|
|
|
dc8c34 |
+ * If a_deleted_values is empty && if a_deletioncsn is NULL,
|
|
|
dc8c34 |
+ * a_deletioncsn is initialized via valueset_add_string.
|
|
|
dc8c34 |
+ * The size needs to be added.
|
|
|
dc8c34 |
+ */
|
|
|
dc8c34 |
+ /* ";adcsn-" + a->a_deletioncsn */
|
|
|
dc8c34 |
+ elen += 1 + LDIF_CSNPREFIX_MAXLENGTH + CSN_STRSIZE;
|
|
|
dc8c34 |
+ /*
|
|
|
dc8c34 |
+ * When both a_present_values & a_deleted_values are empty,
|
|
|
dc8c34 |
+ * the type size is not added.
|
|
|
dc8c34 |
+ */
|
|
|
dc8c34 |
+ elen += PL_strlen(a->a_type);
|
|
|
dc8c34 |
}
|
|
|
dc8c34 |
}
|
|
|
dc8c34 |
}
|
|
|
dc8c34 |
@@ -1766,10 +1777,8 @@ entry2str_internal_ext( Slapi_Entry *e, int *len, int entry2str_ctrl)
|
|
|
dc8c34 |
if (NULL != slapi_entry_get_rdn_const(e))
|
|
|
dc8c34 |
{
|
|
|
dc8c34 |
slapi_value_set_string(&rdnvalue, slapi_entry_get_rdn_const(e));
|
|
|
dc8c34 |
- elen += entry2str_internal_size_value("rdn", &rdnvalue,
|
|
|
dc8c34 |
- entry2str_ctrl,
|
|
|
dc8c34 |
- ATTRIBUTE_PRESENT,
|
|
|
dc8c34 |
- VALUE_PRESENT);
|
|
|
dc8c34 |
+ elen += entry2str_internal_size_value("rdn", &rdnvalue, entry2str_ctrl,
|
|
|
dc8c34 |
+ ATTRIBUTE_PRESENT, VALUE_PRESENT);
|
|
|
dc8c34 |
}
|
|
|
dc8c34 |
|
|
|
dc8c34 |
/* Count the space required for the present attributes */
|
|
|
dc8c34 |
--
|
|
|
dc8c34 |
2.7.4
|
|
|
dc8c34 |
|