Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions v3/control.go
Original file line number Diff line number Diff line change
Expand Up @@ -755,7 +755,7 @@ func NewControlServerSideSorting(value *ber.Packet) (*ControlServerSideSorting,
sequences := val[0].Children

for i, sequence := range sequences {
sortKey := &SortKey{}
sortKey := new(SortKey)

if len(sequence.Children) < 2 {
return nil, fmt.Errorf("attributeType or matchingRule is missing from sequence %d", i)
Expand Down Expand Up @@ -864,19 +864,22 @@ func (c ControlServerSideSortingCode) Valid() error {
}

func NewControlServerSideSortingResult(pkt *ber.Packet) (*ControlServerSideSortingResult, error) {
control := &ControlServerSideSortingResult{}
control := new(ControlServerSideSortingResult)

if pkt == nil || len(pkt.Children) == 0 {
return nil, fmt.Errorf("bad packet")
// This is currently not compliant with the ServerSideSorting RFC (see https://datatracker.ietf.org/doc/html/rfc2891#section-1.2).
// but it's necessary because there seems to be a bug in the implementation of the popular OpenLDAP server.
//
// See: https://github.com/go-ldap/ldap/pull/546
return control, nil
}

codeInt, err := ber.ParseInt64(pkt.Children[0].Data.Bytes())
if err != nil {
return nil, err
}

code := ControlServerSideSortingCode(codeInt)
if err := code.Valid(); err != nil {
if err = ControlServerSideSortingCode(codeInt).Valid(); err != nil {
return nil, err
}

Expand Down