Skip to content

Commit

Permalink
cpio: multiple fixes in list_item_verbose()
Browse files Browse the repository at this point in the history
Do not call strftime() with NULL timeptr
Adjust uids and gids buffers as cpio_i64toa() may return up to 22 bytes

Fixes libarchive#1934
Fixes libarchive#1935
  • Loading branch information
mmatuska committed Jul 25, 2023
1 parent 3cfae35 commit ee312cf
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions cpio/cpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -1146,7 +1146,7 @@ list_item_verbose(struct cpio *cpio, struct archive_entry *entry)
{
char size[32];
char date[32];
char uids[16], gids[16];
char uids[22], gids[22];
const char *uname, *gname;
FILE *out = stdout;
const char *fmt;
Expand Down Expand Up @@ -1210,7 +1210,10 @@ list_item_verbose(struct cpio *cpio, struct archive_entry *entry)
#else
ltime = localtime(&mtime);
#endif
strftime(date, sizeof(date), fmt, ltime);
if (ltime != NULL)
strftime(date, sizeof(date), fmt, ltime);
else
strcpy(date, "invalid mtime");

fprintf(out, "%s%3d %-8s %-8s %8s %12s %s",
archive_entry_strmode(entry),
Expand Down

0 comments on commit ee312cf

Please sign in to comment.