Fork github.com/mattn/go-sqlite3 with adjustment for go1.16.2
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
477 B

  1. package sqlite3_fuzz
  2. import (
  3. "bytes"
  4. "database/sql"
  5. "io/ioutil"
  6. _ "github.com/mattn/go-sqlite3"
  7. )
  8. func FuzzOpenExec(data []byte) int {
  9. sep := bytes.IndexByte(data, 0)
  10. if sep <= 0 {
  11. return 0
  12. }
  13. err := ioutil.WriteFile("/tmp/fuzz.db", data[sep+1:], 0644)
  14. if err != nil {
  15. return 0
  16. }
  17. db, err := sql.Open("sqlite3", "/tmp/fuzz.db")
  18. if err != nil {
  19. return 0
  20. }
  21. defer db.Close()
  22. _, err = db.Exec(string(data[:sep-1]))
  23. if err != nil {
  24. return 0
  25. }
  26. return 1
  27. }