-
Notifications
You must be signed in to change notification settings - Fork 103
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
Fix u32 parse panic in decode_csv #288
Fix u32 parse panic in decode_csv #288
Conversation
2df6fd9
to
af005c6
Compare
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.
Many thanks!
src/error.rs
Outdated
@@ -12,6 +12,8 @@ pub enum Error { | |||
DecompressingError(std::io::Error), | |||
/// An error occured when decoding a base64 encoded dataset. | |||
Base64DecodingError(base64::DecodeError), | |||
/// An error occurred when decoding a csv encoded dataset. | |||
CsvDecodingError(String), |
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.
I'd prefer that this were an error type so the user could handle it (or format it some other way) if necessary
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.
I think we have several options here. One option would be
CsvDecodingError(Box<dyn std::error::Error + Send + Sync + 'static>)
Alternatively, we could do something like
/// Errors that can occur while decoding csv data.
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum CsvError {
TileDataParseError(ParseIntError)
}
/// Errors which occurred when parsing the file
#[derive(Debug)]
#[non_exhaustive]
pub enum Error {
<SNIP>
/// An error occurred when decoding a csv encoded dataset.
CsvDecodingError(CsvError),
Do you have a preference?
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.
Second one looks better IMO: Lets you look into the error, like in the other enum variants.
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.
LGTM!
I forgot to check for the changelog again x_x I'll update it when the version gets released I guess |
@aleokdev Heh, we should probably look into adding a workflow warning about this. :D |
I have one set up for another project as a GH action, I'll look into importing it whenever possible if you'd like. |
This PR fixes an unhandled parsing error in
decode_csv
found withcargo fuzz
. The following input no longer causes a panic: