Skip to content

bug: reading edit list packets fails when skipping bytes to the end of the file #4

@mmalenic

Description

@mmalenic

When decrypting and reading edit list packets, the last edit list skip causes a panic if it goes to the end of the data stream. In this loop:

crypt4gh-rust/src/lib.rs

Lines 516 to 522 in 2d41a17

loop {
let n = decrypted.read(SEGMENT_SIZE)?;
//log::debug!("body_decrypt_parts()'s reading until the end index: {}", n);
if n == 0 {
break;
}
}
The code tries to read a segment even though there is no data remaining in the read_buffer. This later causes decrypt_block to panic because it gets passed a slice with no data:
let (nonce_slice, data) = ciphersegment.split_at(12);

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions