Skip to content

Commit

Permalink
Fix untar not handling unknown tar entries (extended headers)
Browse files Browse the repository at this point in the history
Fixes issue with Stellare plugins not loading
  • Loading branch information
danngreen committed Nov 25, 2024
1 parent 4aa4c17 commit 6731b33
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
1 change: 1 addition & 0 deletions firmware/src/dynload/plugin_loader.hh
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ public:

if (so_buffer.size() == 0) {
status.error_message = "Error: no plugin .so file found. Plugin is corrupted?";
status.state = State::Error;
break;
}

Expand Down
11 changes: 6 additions & 5 deletions firmware/src/fs/asset_drive/untar.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ struct TarRaw {
DIRECTORY = '5',
FIFO = '6',
CONTIGUOUS = '7',
EXTENDED_HDR = 'x',
};
};
static_assert(sizeof(TarRaw) == 512);
Expand Down Expand Up @@ -99,12 +100,12 @@ Archive::Archive(std::span<const char> filedata)

auto type = is_file(buffer.type) ? TarEntry::File : is_dir(buffer.type) ? TarEntry::Dir : TarEntry::Unknown;
if (type == TarEntry::Unknown) {
pr_err("Unknown tar entry type (not Dir or File): %d\n", buffer.type);
break;
}
pr_err("Unknown tar entry type (not Dir or File): 0x%x, name = %.100s\n", buffer.type, buffer.name);
} else {

// Cannot use emplace_back with earlier Clang
archive.push_back({.name = entry_name(&buffer), .size = size, .file_offset = offset, .type = type});
// Cannot use emplace_back with earlier Clang
archive.push_back({.name = entry_name(&buffer), .size = size, .file_offset = offset, .type = type});
}

// skip over data and unfilled block
unsigned jump = size;
Expand Down

0 comments on commit 6731b33

Please sign in to comment.