From 2a93a58a34c92bac004ec9f0bb2e8cdeed583cad Mon Sep 17 00:00:00 2001 From: ned Date: Tue, 2 Jun 2015 16:15:06 -0600 Subject: Fixed bug with SizeLimit=1 --- server_search.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'server_search.go') diff --git a/server_search.go b/server_search.go index 74d06b9..3fc91c5 100644 --- a/server_search.go +++ b/server_search.go @@ -44,7 +44,8 @@ func HandleSearchRequest(req *ber.Packet, controls *[]Control, messageID uint64, } } - for i, entry := range searchResp.Entries { + i := 0 + for _, entry := range searchResp.Entries { if server.EnforceLDAP { // filter keep, resultCode := ServerApplyFilter(filterPacket, entry) @@ -72,11 +73,6 @@ func HandleSearchRequest(req *ber.Packet, controls *[]Control, messageID uint64, } } - // size limit - if searchReq.SizeLimit > 0 && i >= searchReq.SizeLimit { - break - } - // attributes if len(searchReq.Attributes) > 1 || (len(searchReq.Attributes) == 1 && len(searchReq.Attributes[0]) > 0) { entry, err = filterAttributes(entry, searchReq.Attributes) @@ -84,6 +80,12 @@ func HandleSearchRequest(req *ber.Packet, controls *[]Control, messageID uint64, return NewError(LDAPResultOperationsError, err) } } + + // size limit + if searchReq.SizeLimit > 0 && i >= searchReq.SizeLimit { + break + } + i++ } // respond -- cgit v1.2.3