Closed
Bug 300482
Opened 19 years ago
Closed 18 years ago
ldap_multisort_entries incorrectly return an error code on zero length results
Categories
(Directory :: LDAP C SDK, defect)
Tracking
(Not tracked)
RESOLVED
FIXED
People
(Reporter: mozilla, Assigned: richm)
Details
Attachments
(2 files)
|
602 bytes,
patch
|
Details | Diff | Splinter Review | |
|
947 bytes,
text/plain
|
mcs
:
review+
|
Details |
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.8) Gecko/20050517 Firefox/1.0.4 (Debian package 1.0.4-2) Build Identifier: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.8) Gecko/20050517 Firefox/1.0.4 (Debian package 1.0.4-2) if ldap_multisort_entries is called to sort a search result with 0 entry, it returns a memory error when doing et = (struct entrything *)NSLDAPI_MALLOC( count * sizeof(struct entrything) )) since count = 0. It should behave normally and return a success error code, even if doing nothing. Reproducible: Always Steps to Reproduce: 1.Compile a binary using the c directory, with a sort on client side 2.Run the binary and go via this sort while the filter returns no entry Actual Results: Error code 90 (memory error) is raised Expected Results: No error code with an empty result The issue was generated under sparc solaris 8
| Reporter | ||
Updated•19 years ago
|
OS: other → Solaris
Hardware: Other → Sun
Comment 2•19 years ago
|
||
Thnaks for reporting this bug and providing a patch. I might change the check for count == 0 to count < 2 (no point in sorting one entry either). I will commit the fix soon.
Status: NEW → ASSIGNED
| Reporter | ||
Comment 3•19 years ago
|
||
I had not used < 2 on purposes as count can be == -1 if ldap_count_entries fails to count the entries. On another side, if the count is -1, the malloc of a negative value could be devastating, but the ldap_multisort_entries should then return an error rather than a success as if there were only 0 or 1 entries.
| Assignee | ||
Comment 4•18 years ago
|
||
Mark, can you reassign this to me unless you already have a fix? Thanks.
Updated•18 years ago
|
Assignee: mcs → richm
Status: ASSIGNED → NEW
| Assignee | ||
Comment 5•18 years ago
|
||
I noticed the same problem in keysort above. This version first checks for count < 0 which is the error case. Then it just returns 0 in case count < 2.
Attachment #231591 -
Flags: review?(mcs)
Comment 6•18 years ago
|
||
Comment on attachment 231591 [details]
diffs for fix
OK.
Attachment #231591 -
Flags: review?(mcs) → review+
| Assignee | ||
Comment 7•18 years ago
|
||
Checking in sort.c; /cvsroot/mozilla/directory/c-sdk/ldap/libraries/libldap/sort.c,v <-- sort.c new revision: 5.3; previous revision: 5.2 done
Status: NEW → RESOLVED
Closed: 18 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•