Skip to content
Open
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
3 changes: 1 addition & 2 deletions examples/fuzz_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,8 @@ fn run_for_file_types(data: &[u8]) {
];

for file_type in file_types.iter() {
match Metadata::new_from_vec(&data.to_vec(), *file_type) {
match Metadata::new_from_vec(data, *file_type) {
Ok(metadata) => {
// process_metadata_strict(data, metadata.clone(), *file_type);
process_metadata_non_strict(data, metadata.clone(), *file_type);
clean_metadata(metadata);
}
Expand Down
4 changes: 2 additions & 2 deletions src/exif_tag/decode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ decode_tag_with_format_exceptions
(
raw_tag: &ExifTag,
format: ExifTagFormat,
raw_data: &Vec<u8>,
raw_data: &[u8],
endian: &Endian,
hex_tag: u16,
group: &ExifTagGroup
Expand Down Expand Up @@ -138,7 +138,7 @@ decode_tag_with_format_exceptions
raw_tag.as_u16() == 0x001b && // GPSProcessingMethod
raw_tag.get_group() == ExifTagGroup::GPS
{
return raw_tag.set_value_to_undef(raw_data.clone()).map_err(
return raw_tag.set_value_to_undef(raw_data.to_vec()).map_err(
|e| io_error_plain!(Other, format!("Could not decode tag {:?}: {}", raw_tag, e))
);
}
Expand Down
10 changes: 5 additions & 5 deletions src/exif_tag/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ macro_rules! build_tag_enum {
(
hex_value: u16,
format: &ExifTagFormat,
raw_data: &Vec<u8>,
raw_data: &[u8],
endian: &Endian,
group: &ExifTagGroup,
)
Expand All @@ -178,11 +178,11 @@ macro_rules! build_tag_enum {
)),
)*

(0x0111, _) => Ok(ExifTag::StripOffsets( <INT32U as U8conversion<INT32U>>::from_u8_vec(&raw_data, endian), Vec::new())),
(0x0117, _) => Ok(ExifTag::StripByteCounts(<INT32U as U8conversion<INT32U>>::from_u8_vec(&raw_data, endian), )),
(0x0111, _) => Ok(ExifTag::StripOffsets( <INT32U as U8conversion<INT32U>>::from_u8_vec(raw_data, endian), Vec::new())),
(0x0117, _) => Ok(ExifTag::StripByteCounts(<INT32U as U8conversion<INT32U>>::from_u8_vec(raw_data, endian), )),

(0x0201, _) => Ok(ExifTag::ThumbnailOffset(<INT32U as U8conversion<INT32U>>::from_u8_vec(&raw_data, endian), Vec::new())),
(0x0202, _) => Ok(ExifTag::ThumbnailLength(<INT32U as U8conversion<INT32U>>::from_u8_vec(&raw_data, endian), )),
(0x0201, _) => Ok(ExifTag::ThumbnailOffset(<INT32U as U8conversion<INT32U>>::from_u8_vec(raw_data, endian), Vec::new())),
(0x0202, _) => Ok(ExifTag::ThumbnailLength(<INT32U as U8conversion<INT32U>>::from_u8_vec(raw_data, endian), )),

_ => {
// In this case, the given hex_value represents a tag that is unknown
Expand Down
2 changes: 1 addition & 1 deletion src/ifd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ ImageFileDirectory
pub(crate) fn
decode_ifd
(
data_cursor: &mut Cursor<&Vec<u8>>,
data_cursor: &mut Cursor<&[u8]>,
data_begin_position: u64, // Stays the same for all calls to this function while decoding
endian: & Endian,
group: & ExifTagGroup,
Expand Down
2 changes: 1 addition & 1 deletion src/jpg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ file_write_metadata
pub(crate) fn
read_metadata
(
file_buffer: &Vec<u8>
file_buffer: &[u8]
)
-> Result<Vec<u8>, std::io::Error>
{
Expand Down
4 changes: 2 additions & 2 deletions src/jxl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ box_contains_exif
pub(crate) fn
read_metadata
(
file_buffer: &Vec<u8>
file_buffer: &[u8]
)
-> Result<Vec<u8>, std::io::Error>
{
Expand Down Expand Up @@ -411,7 +411,7 @@ encode_metadata_jxl
fn
find_insert_position
(
file_buffer: &Vec<u8>
file_buffer: &[u8]
)
-> Result<usize, std::io::Error>
{
Expand Down
2 changes: 1 addition & 1 deletion src/metadata/metadata_io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Metadata
pub fn
new_from_vec
(
file_buffer: &Vec<u8>,
file_buffer: &[u8],
file_type: FileExtension
)
-> Result<Metadata, std::io::Error>
Expand Down
4 changes: 2 additions & 2 deletions src/metadata/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ Metadata
{
if let Ok(pre_decode_general) = raw_pre_decode_general
{
let mut pre_decode_cursor = Cursor::new(&pre_decode_general);
let mut pre_decode_cursor = Cursor::new(pre_decode_general.as_slice());
let decoding_result = Self::decode(&mut pre_decode_cursor);
if let Ok((endian, image_file_directories)) = decoding_result
{
Expand Down Expand Up @@ -246,7 +246,7 @@ Metadata
fn
decode
(
data_cursor: &mut Cursor<&Vec<u8>>
data_cursor: &mut Cursor<&[u8]>
)
-> Result<(Endian, Vec<ImageFileDirectory>), std::io::Error>
{
Expand Down
16 changes: 8 additions & 8 deletions src/png/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ fn encode_byte(byte: &u8) -> [u8; 2]
fn
check_signature
(
file_buffer: &Vec<u8>
file_buffer: &[u8]
)
-> Result<Cursor<&Vec<u8>>, std::io::Error>
-> Result<Cursor<&[u8]>, std::io::Error>
{
if !file_buffer.starts_with(&PNG_SIGNATURE)
{
Expand Down Expand Up @@ -108,7 +108,7 @@ file_check_signature
return io_error!(InvalidData, "Can't open PNG file - Can't read signature!");
}

check_signature(&signature_buffer.to_vec())?;
check_signature(signature_buffer.as_ref())?;

// Signature is valid - can proceed using the file as PNG file
return Ok(file);
Expand All @@ -123,7 +123,7 @@ file_check_signature
pub(crate) fn
vec_parse_png
(
file_buffer: &Vec<u8>
file_buffer: &[u8]
)
-> Result<Vec<PngChunk>, std::io::Error>
{
Expand Down Expand Up @@ -232,7 +232,7 @@ get_next_chunk_descriptor
pub(crate) fn
read_metadata
(
file_buffer: &Vec<u8>
file_buffer: &[u8]
)
-> Result<Vec<u8>, std::io::Error>
{
Expand Down Expand Up @@ -695,7 +695,7 @@ generic_write_metadata
fn
encode_metadata_png
(
exif_vec: &Vec<u8>
exif_vec: &[u8]
)
-> Vec<u8>
{
Expand Down Expand Up @@ -740,7 +740,7 @@ encode_metadata_png
fn
decode_metadata_png
(
encoded_data: &Vec<u8>
encoded_data: &[u8]
)
-> Result<Vec<u8>, std::io::Error>
{
Expand Down Expand Up @@ -902,7 +902,7 @@ decode_metadata_png
pub(crate) fn
as_u8_vec
(
general_encoded_metadata: &Vec<u8>,
general_encoded_metadata: &[u8],
as_zTXt_chunk: bool
)
-> Vec<u8>
Expand Down
2 changes: 1 addition & 1 deletion src/tiff/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use super::generic_write_metadata;
pub(crate) fn
read_metadata
(
file_buffer: &Vec<u8>
file_buffer: &[u8]
)
-> Result<Vec<u8>, std::io::Error>
{
Expand Down
16 changes: 8 additions & 8 deletions src/webp/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ use super::*;
fn
check_signature
(
file_buffer: &Vec<u8>
file_buffer: &[u8]
)
-> Result<Cursor<&Vec<u8>>, std::io::Error>
-> Result<Cursor<&[u8]>, std::io::Error>
{
if file_buffer.len() < 12
{
Expand All @@ -50,7 +50,7 @@ check_signature
fn
get_next_chunk
(
cursor: &mut Cursor<&Vec<u8>>
cursor: &mut Cursor<&[u8]>
)
-> Result<RiffChunk, std::io::Error>
{
Expand Down Expand Up @@ -106,7 +106,7 @@ get_next_chunk
fn
get_next_chunk_descriptor
(
cursor: &mut Cursor<&Vec<u8>>
cursor: &mut Cursor<&[u8]>
)
-> Result<RiffChunkDescriptor, std::io::Error>
{
Expand All @@ -122,7 +122,7 @@ get_next_chunk_descriptor
pub(crate) fn
parse_webp
(
file_buffer: &Vec<u8>
file_buffer: &[u8]
)
-> Result<Vec<RiffChunkDescriptor>, std::io::Error>
{
Expand Down Expand Up @@ -190,9 +190,9 @@ parse_webp
fn
check_exif_in_file
(
file_buffer: &Vec<u8>
file_buffer: &[u8]
)
-> Result<(Cursor<&Vec<u8>>, Vec<RiffChunkDescriptor>), std::io::Error>
-> Result<(Cursor<&[u8]>, Vec<RiffChunkDescriptor>), std::io::Error>
{
// Parse the WebP file - if this fails, we surely can't read any metadata
let parsed_webp_result = parse_webp(file_buffer)?;
Expand Down Expand Up @@ -249,7 +249,7 @@ check_exif_in_file
pub(crate) fn
read_metadata
(
file_buffer: &Vec<u8>
file_buffer: &[u8]
)
-> Result<Vec<u8>, std::io::Error>
{
Expand Down
2 changes: 1 addition & 1 deletion tests/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ read_from_file_avif()
fn
read_from_vec_generic
(
image_data: &Vec<u8>,
image_data: &[u8],
filetype: little_exif::filetype::FileExtension
)
-> Result<(), std::io::Error>
Expand Down