Skip to content

Commit c1630fc

Browse files
AdamKorcztz70s
authored andcommitted
Add fuzzer (go-sql-driver#1097)
The fuzzer targets the `Open` function, which can be run locally as well as through oss-fuzz's infrastructure.
1 parent 3408884 commit c1630fc

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

fuzz.go

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Go MySQL Driver - A MySQL-Driver for Go's database/sql package.
2+
//
3+
// Copyright 2020 The Go-MySQL-Driver Authors. All rights reserved.
4+
//
5+
// This Source Code Form is subject to the terms of the Mozilla Public
6+
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
7+
// You can obtain one at http://mozilla.org/MPL/2.0/.
8+
9+
// +build gofuzz
10+
11+
package mysql
12+
13+
import (
14+
"database/sql"
15+
)
16+
17+
func Fuzz(data []byte) int {
18+
db, err := sql.Open("mysql", string(data))
19+
if err != nil {
20+
return 0
21+
}
22+
db.Close()
23+
return 1
24+
}

0 commit comments

Comments
 (0)