Skip to content
This repository has been archived by the owner on Feb 27, 2023. It is now read-only.

Commit

Permalink
Added 2 fuzzers
Browse files Browse the repository at this point in the history
Signed-off-by: Adam Korczynski <[email protected]>
  • Loading branch information
AdamKorcz authored and lowzj committed May 13, 2020
1 parent 164e390 commit 6e7e41d
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 0 deletions.
26 changes: 26 additions & 0 deletions dfget/core/uploader/uploader_fuzz.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Copyright The Dragonfly Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package uploader

func FuzzParseParams(data []byte) int {
s := string(data)
_, err := parseParams(s, s, s)
if err != nil {
return 0
}
return 1
}
37 changes: 37 additions & 0 deletions supernode/daemon/mgr/cdn/cdn_fuzz.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright The Dragonfly Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package cdn

import (
"bytes"
"context"
"io/ioutil"

"github.com/sirupsen/logrus"
)

func Fuzz(data []byte) int {
// Don't spam output with parse failures
logrus.SetOutput(ioutil.Discard)
r := bytes.NewReader(data)
sr := newSuperReader()
_, err := sr.readFile(context.Background(), r, true, true)
if err != nil {
return 0
}
return 1
}

0 comments on commit 6e7e41d

Please sign in to comment.