Fix a memory bug in ldap's ParseDN function by disabling part of the functionality
Signed-off-by: Tim Ramlot <42113979+inteon@users.noreply.github.com>
This commit is contained in:
parent
a22d1d673a
commit
4a8b8c4e09
@ -268,3 +268,12 @@ func TestMustKeepOrderInRawDerBytes(t *testing.T) {
|
||||
assert.Equal(t, expectedRdnSeq, rdnSeq)
|
||||
assert.Equal(t, subject, rdnSeq.String())
|
||||
}
|
||||
|
||||
func TestShouldFailForHexDER(t *testing.T) {
|
||||
_, err := ParseSubjectStringToRawDERBytes("DF=#6666666666665006838820013100000746939546349182108463491821809FBFFFFFFFFF")
|
||||
if err == nil {
|
||||
t.Fatal("expected error, but got none")
|
||||
}
|
||||
|
||||
assert.Contains(t, err.Error(), "unsupported distinguished name (DN) \"DF=#6666666666665006838820013100000746939546349182108463491821809FBFFFFFFFFF\": notation does not support x509.subject identities containing \"=#\"")
|
||||
}
|
||||
|
||||
@ -21,6 +21,8 @@ import (
|
||||
"crypto/x509/pkix"
|
||||
"encoding/asn1"
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/go-ldap/ldap/v3"
|
||||
)
|
||||
@ -66,6 +68,10 @@ var attributeTypeNames = map[string][]int{
|
||||
}
|
||||
|
||||
func UnmarshalSubjectStringToRDNSequence(subject string) (pkix.RDNSequence, error) {
|
||||
if strings.Contains(subject, "=#") {
|
||||
return nil, fmt.Errorf("unsupported distinguished name (DN) %q: notation does not support x509.subject identities containing \"=#\"", subject)
|
||||
}
|
||||
|
||||
dns, err := ldap.ParseDN(subject)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
Loading…
Reference in New Issue
Block a user