Skip to content

Commit 50991e3

Browse files
cgwaltersallisonkarlitskaya
authored andcommitted
splitstream: Add a test case for previous change
I verified this passes now and fails without the previous commit. Signed-off-by: Colin Walters <[email protected]>
1 parent a9d9272 commit 50991e3

File tree

1 file changed

+35
-1
lines changed
  • crates/composefs-oci/src

1 file changed

+35
-1
lines changed

crates/composefs-oci/src/tar.rs

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,8 @@ pub fn get_entry<R: Read, ObjectID: FsVerityHashValue>(
284284
mod tests {
285285
use super::*;
286286
use composefs::{
287-
fsverity::Sha256HashValue, repository::Repository, splitstream::SplitStreamReader,
287+
fsverity::Sha256HashValue, generic_tree::LeafContent, repository::Repository,
288+
splitstream::SplitStreamReader,
288289
};
289290
use std::{io::Cursor, path::Path, sync::Arc};
290291
use tar::Builder;
@@ -618,6 +619,39 @@ mod tests {
618619
assert_eq!(entries[0].path, Path::new(&abspath));
619620
}
620621

622+
#[test]
623+
fn test_gnu_longlink() {
624+
let very_long_path = format!(
625+
"very/long/path/that/exceeds/the/normal/tar/header/limit/{}",
626+
"x".repeat(120)
627+
);
628+
629+
// Use append_data to create a tar with a very long filename that triggers GNU extensions
630+
let mut tar_data = Vec::new();
631+
{
632+
let mut builder = Builder::new(&mut tar_data);
633+
let mut header = tar::Header::new_gnu();
634+
header.set_mode(0o777);
635+
header.set_entry_type(EntryType::Symlink);
636+
header.set_size(0);
637+
header.set_uid(0);
638+
header.set_gid(0);
639+
builder
640+
.append_link(&mut header, "long-symlink", &very_long_path)
641+
.unwrap();
642+
builder.finish().unwrap();
643+
};
644+
645+
let entries = read_all_via_splitstream(tar_data).unwrap();
646+
assert_eq!(entries.len(), 1);
647+
match &entries[0].item {
648+
TarItem::Leaf(LeafContent::Symlink(ref target)) => {
649+
assert_eq!(&**target, OsStr::new(&very_long_path));
650+
}
651+
_ => unreachable!(),
652+
};
653+
}
654+
621655
/// Compare a tar::Header with a composefs Stat structure for equality
622656
fn assert_header_stat_equal(header: &tar::Header, stat: &Stat, msg_prefix: &str) {
623657
assert_eq!(

0 commit comments

Comments
 (0)