-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #300 from mapeditor/next
Merge next into current
- Loading branch information
Showing
21 changed files
with
583 additions
and
108 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
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<map version="1.10" tiledversion="1.10.2" orientation="orthogonal" renderorder="right-down" width="2" height="2" tilewidth="32" tileheight="32" infinite="0" nextlayerid="3" nextobjectid="4"> | ||
<layer id="1" name="Tile Layer 1" width="2" height="2"> | ||
<data encoding="csv"> | ||
0,0, | ||
0,0 | ||
</data> | ||
</layer> | ||
<objectgroup id="2" name="Object Layer 1"> | ||
<object id="2" x="0" y="0" width="32" height="32"> | ||
<properties> | ||
<property name="class property" type="class" propertytype="test_type"> | ||
<properties> | ||
<property name="test_property_1" type="int" value="3"/> | ||
</properties> | ||
</property> | ||
<property name="empty property" type="class" propertytype="empty_type"/> | ||
</properties> | ||
</object> | ||
</objectgroup> | ||
</map> |
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,8 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<map version="1.10" tiledversion="1.10.2" orientation="orthogonal" renderorder="right-down" width="1" height="1" tilewidth="16" tileheight="16" infinite="0" nextlayerid="3" nextobjectid="2"> | ||
<objectgroup id="2" name="Object Layer 1"> | ||
<object id="1" x="-24.1094" y="-2.39844" width="87.7188" height="21.7969"> | ||
<text color="#6455ff7f" bold="1" italic="1" underline="1" strikeout="1" halign="center" valign="bottom">Test</text> | ||
</object> | ||
</objectgroup> | ||
</map> |
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
target | ||
corpus | ||
artifacts | ||
coverage |
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,24 @@ | ||
[package] | ||
name = "tiled-fuzz" | ||
version = "0.0.0" | ||
publish = false | ||
edition = "2018" | ||
|
||
[package.metadata] | ||
cargo-fuzz = true | ||
|
||
[dependencies] | ||
libfuzzer-sys = "0.4" | ||
|
||
[build-dependencies] | ||
glob = "0.3.1" | ||
|
||
[dependencies.tiled] | ||
path = ".." | ||
|
||
[[bin]] | ||
name = "tiled" | ||
path = "fuzz_targets/tiled.rs" | ||
test = false | ||
doc = false | ||
bench = false |
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,28 @@ | ||
use std::path::PathBuf; | ||
|
||
use glob::glob; | ||
|
||
macro_rules! p { | ||
($($tokens: tt)*) => { | ||
println!("cargo:warning={}", format!($($tokens)*)) | ||
} | ||
} | ||
|
||
fn main() { | ||
let path = PathBuf::from(env!("CARGO_MANIFEST_DIR")); | ||
let corpus_dir = path.join("corpus/tiled"); | ||
std::fs::create_dir_all(&corpus_dir).expect("failed creating corpus dir"); | ||
|
||
let tmx_assets_path = path.join("../assets/*.tmx"); | ||
for entry in glob(tmx_assets_path.to_str().unwrap()).unwrap() { | ||
match entry { | ||
Ok(src) => { | ||
let dest = corpus_dir.join(src.file_name().unwrap()); | ||
std::fs::copy(src, dest).unwrap(); | ||
} | ||
Err(e) => { | ||
p!("{:?}", e) | ||
} | ||
} | ||
} | ||
} |
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 @@ | ||
#![no_main] | ||
|
||
use libfuzzer_sys::fuzz_target; | ||
|
||
use std::path::Path; | ||
|
||
use tiled::{DefaultResourceCache, Loader, ResourceReader}; | ||
|
||
struct FuzzResourceReader<'a> { | ||
data: &'a [u8], | ||
} | ||
|
||
impl<'a> FuzzResourceReader<'a> { | ||
fn new(data: &'a [u8]) -> Self { | ||
FuzzResourceReader { data } | ||
} | ||
} | ||
|
||
impl<'a> ResourceReader for FuzzResourceReader<'a> { | ||
type Resource = &'a [u8]; | ||
type Error = std::io::Error; | ||
|
||
fn read_from(&mut self, _path: &Path) -> Result<Self::Resource, Self::Error> { | ||
Ok(self.data) | ||
} | ||
} | ||
|
||
fuzz_target!(|data: &[u8]| { | ||
let mut loader = | ||
Loader::with_cache_and_reader(DefaultResourceCache::new(), FuzzResourceReader::new(data)); | ||
let _ = loader.load_tmx_map("fuzz.tmx"); | ||
}); |
Oops, something went wrong.