Message Id - ASN.1 erreur encodage #3

Closed
opened 2021-07-08 09:13:11 +00:00 by erwan · 0 comments
Member

Problem of unsigned/signed int with the message ID. When the value is 128, he writes on an alone byte. So we get the value -128 and this declare a fatal error in client(goldap).

Reproduct the bug:

func main() {
	//... l is your *ldap.Conn
    for i := 0; i < 250; i++ {
    	req := ldap.NewAddRequest(dn, nil)
    	req.Attribute(name, value)
		
        err:= l.Add(req)
		if err != nil {
        	log.Fatal(err)
        }
	}
    

Expected Result:

In normal case, the program run without error output and send 250 requests.

Results obtained:

We obtain this error:
2021/07/07 01:25:51 Received unexpected message -128, false

Hypothetic source of the bug:

We can suggest invest the encodage ASN.1 which is incorrect for the integer numbers. It's a problem of unsigned/signed int.

Hack to workaround this bug:

You need only to reconnect to reinitialize the counter ID.

//Handler to around the bug with MessageId
func (inst *instance) Reconnect() (err error) {
	//inst.logging -> the pointer *ldap.Conn
	inst.logging.Close()
	inst.logging, err = ldap.Dial("tcp", fmt.Sprintf("%s:%d", adresse, port))
	if err != nil {
		return
	}
	err = inst.logging.Bind(bindusername, bindpassword)
	//logging.Debug("Reconnect succesful")
	return
}
Problem of unsigned/signed int with the message ID. When the value is 128, he writes on an alone byte. So we get the value -128 and this declare a fatal error in client(goldap). #### Reproduct the bug: ```go func main() { //... l is your *ldap.Conn for i := 0; i < 250; i++ { req := ldap.NewAddRequest(dn, nil) req.Attribute(name, value) err:= l.Add(req) if err != nil { log.Fatal(err) } } ``` #### Expected Result: In normal case, the program run without error output and send 250 requests. #### Results obtained: We obtain this error: `2021/07/07 01:25:51 Received unexpected message -128, false` #### Hypothetic source of the bug: We can suggest invest the encodage **ASN.1** which is incorrect for the integer numbers. It's a problem of unsigned/signed int. #### Hack to workaround this bug: You need only to reconnect to reinitialize the counter ID. ```go //Handler to around the bug with MessageId func (inst *instance) Reconnect() (err error) { //inst.logging -> the pointer *ldap.Conn inst.logging.Close() inst.logging, err = ldap.Dial("tcp", fmt.Sprintf("%s:%d", adresse, port)) if err != nil { return } err = inst.logging.Bind(bindusername, bindpassword) //logging.Debug("Reconnect succesful") return } ```
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: Deuxfleurs/bottin#3
No description provided.