https://bugs.openldap.org/show_bug.cgi?id=10162
Issue ID: 10162
Summary: Fix for binary attributes data corruption in back-sql
Product: OpenLDAP
Version: unspecified
Hardware: All
OS: All
Status: UNCONFIRMED
Keywords: needs_review
Severity: normal
Priority: ---
Component: backends
Assignee: bugs(a)openldap.org
Reporter: dex.tracers(a)gmail.com
Target Milestone: ---
Created attachment 1006
--> https://bugs.openldap.org/attachment.cgi?id=1006&action=edit
Fix for binary attributes corruption on backed-sql
I've configured slapd to use back-sql (mariadb through odbc) and observed
issues with the BINARY data retrievals from the database. The length of the
attributes was properly reported, but the correct data inside was always 16384
bytes and after that point - some junk (usually filled-up with AAAAAAAA and
some other attributes data from memory).
During the debugging - I've noticed that:
- The MAX_ATTR_LEN (16384 bytes) is used to set the length of the data for
BINARY columns when SQLBindCol is done inside of the
"backsql_BindRowAsStrings_x" function
- After SQLFetch is done - data in row->cols[i] is fetched up to the specified
MAX_ATTR_LEN
- After SQLFetch is done - the correct data size (greater than MAX_ATTR_LEN) is
represented inside of the row->value_len
I'm assuming that slapd allocates the pointer in memory (row->cols[i]), fills
it with the specified amount of data (MAX_ATTR_LEN), but when forming the
actual attribute data - uses the length from row->value_len and so everything
from 16384 bytes position till row->value_len is just a junk from the memory
(uninitialized, leftovers, data from other variables).
After an investigation, I've find-out that:
- for BINARY or variable length fields - SQLGetData should be used
- SQLGetData supports chunked mode (if length is unknown) or full-read mode if
the length is known
- it could be used in pair with SQLBindCol after SQLFetch (!)
Since we have the correct data length inside of row->value_len, I've just added
the code to the backsql_get_attr_vals() function to overwrite the corrupted
data with the correct data by issuing SQLGetData request. And it worked -
binary data was properly retrieved and reported over LDAP!
My current concerns / help needed - I'm not very familiar with the memory
allocation/deallocation mechanisms, so I'm afraid that mentioned change can
lead to memory corruption (so far not observed).
Please review attached patch (testing was done on OPENLDAP_REL_ENG_2_5_13, and
applied on the master branch for easier review/application).
--
You are receiving this mail because:
You are on the CC list for the issue.
https://bugs.openldap.org/show_bug.cgi?id=10503
Quanah Gibson-Mount <quanah(a)openldap.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |TEST
Status|IN_PROGRESS |RESOLVED
--- Comment #6 from Quanah Gibson-Mount <quanah(a)openldap.org> ---
head:
• 9b55792b
by Howard Chu at 2026-05-19T16:39:09+00:00
ITS#10503 authzTo: reject member attributes with non-DN syntax
RE27:
• 0c8a5875
by Howard Chu at 2026-05-19T22:36:36+00:00
ITS#10503 authzTo: reject member attributes with non-DN syntax
RE26:
• 41d7478a
by Howard Chu at 2026-05-19T23:00:51+00:00
ITS#10503 authzTo: reject member attributes with non-DN syntax
--
You are receiving this mail because:
You are on the CC list for the issue.
https://bugs.openldap.org/show_bug.cgi?id=9009
--- Comment #1 from Quanah Gibson-Mount <quanah(a)openldap.org> ---
head:
• 6e7690e8
by Howard Chu at 2026-05-19T17:06:20+01:00
ITS#9009 slapd-mdb: fix Makefile for LMDB 1.0
RE27:
• 12656a7c
by Howard Chu at 2026-05-19T22:36:27+00:00
ITS#9009 slapd-mdb: fix Makefile for LMDB 1.0
--
You are receiving this mail because:
You are on the CC list for the issue.
https://bugs.openldap.org/show_bug.cgi?id=10503
Quanah Gibson-Mount <quanah(a)openldap.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |2.6.14
Keywords|needs_review |
Assignee|bugs(a)openldap.org |hyc(a)openldap.org
--
You are receiving this mail because:
You are on the CC list for the issue.
https://bugs.openldap.org/show_bug.cgi?id=8605
--- Comment #9 from Quanah Gibson-Mount <quanah(a)openldap.org> ---
mdb.master:
2216dbd9ee8d5c7a4b4d22e59e5831ed9cae32af
mdb.master3:
93c460b8e4607558a9faf8f53d65468c25d73a12
mdb/RE1.0:
f3ef35bbfbaaab8984b1a4eeb553643fb507862f
mdb/RE0.9:
8aa8c1976f2d8e7db2240445700053d2a3a53c88
--
You are receiving this mail because:
You are on the CC list for the issue.
https://bugs.openldap.org/show_bug.cgi?id=10503
Quanah Gibson-Mount <quanah(a)openldap.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Group|OpenLDAP-devs |
--
You are receiving this mail because:
You are on the CC list for the issue.
https://bugs.openldap.org/show_bug.cgi?id=8461
Quanah Gibson-Mount <quanah(a)openldap.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution|--- |FIXED
--- Comment #7 from Quanah Gibson-Mount <quanah(a)openldap.org> ---
Fixed by switch to lmdb 1.0
--
You are receiving this mail because:
You are on the CC list for the issue.
https://bugs.openldap.org/show_bug.cgi?id=9009
Quanah Gibson-Mount <quanah(a)openldap.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Status|UNCONFIRMED |RESOLVED
--
You are receiving this mail because:
You are on the CC list for the issue.
https://bugs.openldap.org/show_bug.cgi?id=8461
Issue 8461 depends on issue 9009, which changed state.
Issue 9009 Summary: 2.7: Switch to LMDB v1.0
https://bugs.openldap.org/show_bug.cgi?id=9009
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution|--- |FIXED
--
You are receiving this mail because:
You are on the CC list for the issue.
https://bugs.openldap.org/show_bug.cgi?id=6825
Quanah Gibson-Mount <quanah(a)openldap.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Assignee|bugs(a)openldap.org |ondra(a)mistotebe.net
Target Milestone|2.7.1 |2.7.0
Resolution|--- |TEST
--- Comment #9 from Quanah Gibson-Mount <quanah(a)openldap.org> ---
head:
• 985d420d
by OndÅ™ej KuznÃk at 2026-04-30T19:50:52+00:00
ITS#6825 slapd: add modify_entry helper
• 9d7d8e52
by OndÅ™ej KuznÃk at 2026-04-30T19:50:52+00:00
ITS#6825 slapo-unique: use modify_entry
• a7dd52a9
by OndÅ™ej KuznÃk at 2026-04-30T19:50:52+00:00
ITS#6825 slapo-unique: adjust test
• 85c8e671
by OndÅ™ej KuznÃk at 2026-04-30T19:50:52+00:00
ITS#6825 slapo-constraint: also use modify_entry
• f3a7fa1a
by OndÅ™ej KuznÃk at 2026-04-30T19:50:52+00:00
ITS#6825 back-ldif: also use modify_entry
--
You are receiving this mail because:
You are on the CC list for the issue.