Skip to content

Commit

Permalink
Changed Attribute type from uint16 to int16, NonExistingAttribute = -1
Browse files Browse the repository at this point in the history
  • Loading branch information
lkarlslund committed Apr 21, 2022
1 parent 3cf5c1f commit 60ded9f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
4 changes: 2 additions & 2 deletions modules/engine/attributes.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ var mergeapprovers []mergeapproverinfo
var attributenums []attributeinfo

var (
NonExistingAttribute = NewAttribute("*NON EXISTING ATTRIBUTE*")
NonExistingAttribute = Attribute(-1)

DistinguishedName = NewAttribute("distinguishedName").Single().Unique()
ObjectClass = NewAttribute("objectClass")
Expand Down Expand Up @@ -98,7 +98,7 @@ var (
MetaLAPSInstalled = NewAttribute("_haslaps")
)

type Attribute uint16
type Attribute int16

var attributemutex sync.RWMutex

Expand Down
14 changes: 10 additions & 4 deletions modules/engine/object.go
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,8 @@ func init() {
func (o *Object) setFlex(flexinit ...interface{}) {
var ignoreblanks bool

var attribute Attribute
attribute := NonExistingAttribute

data := avsPool.Get().(AttributeValueSlice)
for _, i := range flexinit {
if i == IgnoreBlanks {
Expand Down Expand Up @@ -724,17 +725,22 @@ func (o *Object) setFlex(flexinit ...interface{}) {
case NoValues:
// Ignore it
case Attribute:
if attribute != 0 && (!ignoreblanks || len(data) > 0) {
o.set(attribute, data)
if attribute != NonExistingAttribute && (!ignoreblanks || len(data) > 0) {
newdata := make(AttributeValueSlice, len(data))
copy(newdata, data)
o.set(attribute, newdata)

data = data[:0]
}
attribute = v
default:
panic("SetFlex called with invalid type in object declaration")
}
}
if attribute != 0 && (!ignoreblanks || len(data) > 0) {
if attribute != NonExistingAttribute && (!ignoreblanks || len(data) > 0) {
o.set(attribute, data)
}
if len(data) > 0 {
data = data[:0]
}
avsPool.Put(data)
Expand Down

0 comments on commit 60ded9f

Please sign in to comment.