cpio: correctly detect end of archive
Signed-off-by: Michael Shaw <m@michaelsshaw.com>
This commit is contained in:
parent
acf469ff71
commit
51928ebca4
1 changed files with 5 additions and 1 deletions
|
|
@ -53,7 +53,7 @@ static ssize_t read_next(fs_t *fs, const char *file, rbtree_t *list, dirent_t **
|
|||
return -ENAMETOOLONG;
|
||||
|
||||
const char *cursor = file + sizeof(struct cpio_newc_header);
|
||||
size_t data_offset = sizeof(struct cpio_newc_header) + ALIGN_UP(name_len, 4);
|
||||
size_t data_offset = ALIGN_UP(sizeof(struct cpio_newc_header) + name_len, 4);
|
||||
|
||||
if (!strncmp(cursor, "./", 2)) {
|
||||
cursor += 2;
|
||||
|
|
@ -66,6 +66,10 @@ static ssize_t read_next(fs_t *fs, const char *file, rbtree_t *list, dirent_t **
|
|||
memcpy(name, cursor, name_len);
|
||||
cursor = file + data_offset;
|
||||
|
||||
if(file_len == 0 && !strcmp(name, CPIO_TRAILER)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
char *parent_path = dirname(name);
|
||||
char *leaf = basename(name);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue