Skip to content

Commit

Permalink
fix: add a setup process in TestMain to prevent DATA RACE as a result…
Browse files Browse the repository at this point in the history
… of changing ber's module global variable for fuzz tests go-ldap#472 (go-ldap#473)
  • Loading branch information
t2y authored and gustavoluvizotto committed Apr 11, 2024
1 parent aa49216 commit 3cacdbe
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions fuzz_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,23 @@
package ldap

import (
ber "github.com/go-asn1-ber/asn1-ber"
"os"
"testing"

ber "github.com/go-asn1-ber/asn1-ber"
)

func FuzzParseDN(f *testing.F) {
func TestMain(m *testing.M) {
// For fuzz tests
// See https://github.com/go-asn1-ber/asn1-ber/blob/04301b4b1c5ff66221f8f8a394f814a9917d678a/fuzz_test.go#L33-L37
// for why this limitation is necessary
ber.MaxPacketLengthBytes = 65536

code := m.Run()
os.Exit(code)
}

func FuzzParseDN(f *testing.F) {
f.Add("*")
f.Add("cn=Jim\\0Test")
f.Add("cn=Jim\\0")
Expand Down

0 comments on commit 3cacdbe

Please sign in to comment.