Skip to content
This repository has been archived by the owner on Aug 17, 2024. It is now read-only.

Handle the case were a line contains non-utf8 characters #57

Merged
merged 3 commits into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .github/workflows/CICD.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,24 @@ jobs:
command: test
args: --all-features

fuzz:
name: Test Suite
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v2

- name: Install cargo-fuzz
uses: taiki-e/install-action@v2
with:
tool: cargo-fuzz

- name: Nightly
run: rustup default nightly

- name: Run Fuzzer
run: cargo +nightly fuzz run ical -- -max_total_time=10

lints:
name: Lints
runs-on: ubuntu-latest
Expand Down
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ license-file = "./LICENSE"
name = "ical"
readme = "./README.md"
repository = "https://github.com/Peltoche/ical-rs"
version = "0.7.0"
version = "0.8.0"

[badges]

Expand All @@ -18,8 +18,8 @@ branch = "master"
repository = "https://travis-ci.org/Peltoche/ical-rs"

[dependencies]
thiserror = "1.0.38"
serde = { version = "1.0.152", features = ["derive"], optional = true }
thiserror = "1.0.50"
serde = { version = "1.0.193", features = ["derive"], optional = true }

[features]
default = ["vcard", "ical"]
Expand Down
4 changes: 4 additions & 0 deletions fuzz/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
target
corpus
artifacts
coverage
26 changes: 26 additions & 0 deletions fuzz/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[package]
name = "ical-fuzz"
version = "0.0.0"
publish = false

[package.metadata]
cargo-fuzz = true

[dependencies]
libfuzzer-sys = "0.4"

[dependencies.ical]
path = ".."

# Prevent this from interfering with workspaces
[workspace]
members = ["."]

[profile.release]
debug = 1

[[bin]]
name = "ical"
path = "fuzz_targets/ical.rs"
test = false
doc = false
12 changes: 12 additions & 0 deletions fuzz/fuzz_targets/ical.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#![no_main]

extern crate libfuzzer_sys;
extern crate ical;


use libfuzzer_sys::fuzz_target;

fuzz_target!(|data: &[u8]| {
let c = std::io::Cursor::new(data);
for _ in ical::IcalParser::new(c) {}
});
3 changes: 1 addition & 2 deletions src/generator/event_builder.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use {ical_property,ical_param};
use parser::ical::component::IcalEvent;
use property::Property;
use {ical_param, ical_property};

#[allow(dead_code)]
pub const ICAL_DATE_FORMAT: &str = "%Y%m%dT%H%M%S";
Expand Down Expand Up @@ -170,7 +170,6 @@ impl Finalizer {
.push(ical_property!("RRULE", value.into()));
Finalizer(self.0)
}

}

#[allow(unused)]
Expand Down
4 changes: 2 additions & 2 deletions src/line.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ impl<B: BufRead> LineRead for LineReader<B> {
} else {
// This is the first iteration, next_start isn't been filled yet.
for line in self.reader.by_ref().lines() {
let line = line.unwrap();
let line = line.ok()?;
self.number += 1;

if !line.is_empty() {
Expand All @@ -130,7 +130,7 @@ impl<B: BufRead> LineRead for LineReader<B> {
}

for line in self.reader.by_ref().lines() {
let mut line = line.unwrap();
let mut line = line.ok()?;

if line.is_empty() {
self.number += 1;
Expand Down
Loading