Skip to content

Commit

Permalink
fix: handle missing sorting control in OpenLDAP response
Browse files Browse the repository at this point in the history
  • Loading branch information
kozlov-e committed Jan 30, 2025
1 parent 5d1b644 commit a55d800
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 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,19 @@ 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")
// Фикс бага, наличие Children для OpenLdap не обязательно.
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

0 comments on commit a55d800

Please sign in to comment.