contentauth / c2pa-rs

Rust SDK for the core C2PA (Coalition for Content Provenance and Authenticity) specification
Other
113 stars 49 forks source link

Panic when reading empty stream #528

Closed ok-nick closed 3 weeks ago

ok-nick commented 1 month ago

Repro:

use std::io::{self, Cursor};

use c2pa::{Builder, Reader, Result};

mod common;
use common::test_signer;

#[test]
fn test_builder_read() -> Result<()> {
    let manifest_def = include_str!("../tests/fixtures/simple_manifest.json");
    let mut source = Cursor::new(include_bytes!("fixtures/sample1.svg"));
    let format = "image/svg+xml";

    let mut builder = Builder::from_json(manifest_def)?;
    let manifest_bytes = builder.sign(&test_signer(), format, &mut source, &mut io::empty())?;

    Reader::from_manifest_data_and_stream(&manifest_bytes, format, Cursor::new(vec![]))?;

    Ok(())
}

Error:

thread 'test_builder_read' panicked at sdk/src/utils/hash_utils.rs:247:28:
attempt to subtract with overflow
github-jira-sync-bot commented 1 month ago

Unfortunately, not enough information was provided to create a Jira ticket. Please make sure you added the following label(s): accepted

Once all required labels are present, please add bug label again.

github-jira-sync-bot commented 1 month ago

:white_check_mark: Jira issue https://jira.corp.adobe.com/browse/CAI-6194 is successfully created for this GitHub issue.

Coolkaba commented 1 month ago

Repro:

use std::io::{self, Cursor};

use c2pa::{Builder, Reader, Result};

mod common;
use common::test_signer;

#[test]
fn test_builder_read() -> Result<()> {
    let manifest_def = include_str!("../tests/fixtures/simple_manifest.json");
    let mut source = Cursor::new(include_bytes!("fixtures/sample1.svg"));
    let format = "image/svg+xml";

    let mut builder = Builder::from_json(manifest_def)?;
    let manifest_bytes = builder.sign(&test_signer(), format, &mut source, &mut io::empty())?;

    Reader::from_manifest_data_and_stream(&manifest_bytes, format, Cursor::new(vec![]))?;

    Ok(())
}

Error:

thread 'test_builder_read' panicked at sdk/src/utils/hash_utils.rs:247:28:
attempt to subtract with overflow

thread 'test_builder_read' panicked at sdk/src/utils/hash_utils.rs:247:28: attempt to subtract with overflow

ok-nick commented 3 weeks ago

Fixed in #529