-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fuzz: port fuzz-credential-from-url-gently from OSS-Fuzz
Git's fuzz tests are run continuously as part of OSS-Fuzz [1]. Several additional fuzz tests have been contributed directly to OSS-Fuzz; however, these tests are vulnerable to bitrot because they are not built during Git's CI runs, and thus breaking changes are much less likely to be noticed by Git contributors. Port one of these tests back to the Git project: fuzz-credential-from-url-gently This test was originally contributed to the OSS-Fuzz repo in commit c58ac4492 (Git fuzzing: uncomment the existing and add new targets. (#11486), 2024-02-21). [1] https://github.com/google/oss-fuzz Co-authored-by: Josh Steadmon <[email protected]> Change-Id: I1068cb719d2bee174c3fda141846838469db6e7c Signed-off-by: Josh Steadmon <[email protected]>
- Loading branch information
Showing
4 changed files
with
45 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
fuzz-commit-graph | ||
fuzz-config | ||
fuzz-credential-from-url-gently | ||
fuzz-date | ||
fuzz-pack-headers | ||
fuzz-pack-idx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#include "git-compat-util.h" | ||
#include <stddef.h> | ||
#include <stdlib.h> | ||
#include <stdint.h> | ||
#include <string.h> | ||
#include <stdio.h> | ||
#include "credential.h" | ||
|
||
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size); | ||
|
||
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) | ||
{ | ||
struct credential c; | ||
char *buf; | ||
|
||
buf = malloc(size + 1); | ||
if (!buf) | ||
return 0; | ||
|
||
memcpy(buf, data, size); | ||
buf[size] = 0; | ||
|
||
// start fuzzing | ||
credential_init(&c); | ||
credential_from_url_gently(&c, buf, 1); | ||
|
||
// cleanup | ||
credential_clear(&c); | ||
free(buf); | ||
|
||
return 0; | ||
} |