cade3cd Resolves: bug 231507

Authored and Committed by rmeggins 17 years ago
    Resolves: bug 231507
    Bug Description: Modification of directory entries with VLV-indexed null-value attributes results in server crash
    Reviewed by: nkinder, nhosoi, prowley (Thanks!)
    Fix Description: The value lowest_value is defined outside the loop that loops through all the attributes in the vlv sort specification (e.g. usually something like cn givenname o ou sn if defined by the console browsing index).  lowest_value is not reset for each loop iteration.  So if it goes through the loop one time for e.g. givenname, and givenname has values, lowest_value will point to the lowest value of givenname until the key is created, then it is freed.  So the next loop iteration uses o, and if for example o does not have any values, lowest_value will point to the already freed memory used by the givenname iteration, which is now garbage (e.g. the lowest_value->bv_len may be very large, which is the probably cause of the malloc out of memory errors seen by the customer).  The solution is to reset lowest_value to NULL before each loop iteration (I did this by moving the declaration and initialization of lowest_value inside the loop scope) and testing for lowest_value == NULL before trying to use it.
    Platforms tested: RHEL4
    Flag Day: no
    Doc impact: no
    QA impact: should be covered by regular nightly and manual testing
    New Tests integrated into TET: none