-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[tinyxml2] Update tinyxml2 fuzzer #11985
Merged
Merged
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
0474fcb
[tinyxml2] Update auto_css
gnbon 0e5c0e6
[tinyxml2] Update scripts for tinyxml2 project
gnbon 77d25fc
[tinyxml2] Add centipede fuzzing engine for tinyxml2 project
gnbon 93cd094
[tinyxml2] Add loadfile_fuzzer and rename parse_fuzzer
gnbon 630bc24
[tinyxml2] Add missing license header
gnbon 38dea60
[tinyxml2] Refactor xmltest fuzzer for OSS-Fuzz compatibility
gnbon 98da4c0
[tinyxml2] Fix file path in xmltest2.cpp
gnbon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
|
@@ -3,6 +3,7 @@ language: c++ | |
primary_contact: "[email protected]" | ||
auto_ccs: | ||
- "[email protected]" | ||
- "[email protected]" | ||
sanitizers: | ||
- address | ||
- memory | ||
|
@@ -13,4 +14,5 @@ fuzzing_engines: | |
- afl | ||
- honggfuzz | ||
- libfuzzer | ||
- centipede | ||
|
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,33 +1,28 @@ | ||
#if defined( _MSC_VER ) | ||
#if !defined( _CRT_SECURE_NO_WARNINGS ) | ||
#define _CRT_SECURE_NO_WARNINGS // This test file is not intended to be secure. | ||
#endif | ||
#endif | ||
|
||
#include "tinyxml2/tinyxml2.h" | ||
#include <string> | ||
#include <stddef.h> | ||
#include <stdint.h> | ||
|
||
#if defined( _MSC_VER ) || defined (WIN32) | ||
#include <crtdbg.h> | ||
#define WIN32_LEAN_AND_MEAN | ||
#include <windows.h> | ||
_CrtMemState startMemState; | ||
_CrtMemState endMemState; | ||
#else | ||
#include <sys/stat.h> | ||
#include <sys/types.h> | ||
#endif | ||
|
||
using namespace tinyxml2; | ||
using namespace std; | ||
|
||
// Entry point for LibFuzzer. | ||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { | ||
std::string data_string(reinterpret_cast<const char*>(data), size); | ||
XMLDocument doc; | ||
doc.Parse( data_string.c_str() ); | ||
|
||
return 0; | ||
} | ||
/* Copyright 2024 Google LLC | ||
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. | ||
*/ | ||
|
||
#include "tinyxml2/tinyxml2.h" | ||
|
||
#include <string> | ||
#include <cstdint> | ||
|
||
using namespace tinyxml2; | ||
using namespace std; | ||
|
||
// Entry point for LibFuzzer. | ||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { | ||
std::string data_string(reinterpret_cast<const char*>(data), size); | ||
XMLDocument doc; | ||
doc.Parse( data_string.c_str() ); | ||
|
||
return 0; | ||
} |
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,38 @@ | ||
/* Copyright 2024 Google LLC | ||
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. | ||
*/ | ||
|
||
#include "tinyxml2/tinyxml2.h" | ||
|
||
#include <string> | ||
#include <cstdio> | ||
#include <cstdint> | ||
#include <cstdlib> | ||
|
||
#include <unistd.h> | ||
|
||
using namespace tinyxml2; | ||
using namespace std; | ||
|
||
// Entry point for LibFuzzer. | ||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { | ||
char pathname[256]; | ||
sprintf(pathname, "/dev/shm/fuzz-%d", getpid()); | ||
FILE *fp = fopen(pathname, "wb"); | ||
fwrite(data, size, 1, fp); | ||
fclose(fp); | ||
|
||
XMLDocument doc; | ||
doc.LoadFile(pathname); | ||
|
||
unlink(pathname); | ||
return 0; | ||
} |
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,2 @@ | ||
[libfuzzer] | ||
dict = xml.dict |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does this path always exist?
/dev/shm
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope. Would it be better to modify it like this?
oss-fuzz/projects/binutils/fuzz_addr2line.c
Lines 25 to 26 in 7dc6808