From d8ee4405393045acfc5dcc9f6f87738dafd7ce21 Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Wed, 26 Jun 2019 12:09:27 +0200 Subject: Add support for negative timestamps in pax header Signed-off-by: David Oberhollenzer --- lib/tar/read_header.c | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/lib/tar/read_header.c b/lib/tar/read_header.c index 131f5dc..ec48a3e 100644 --- a/lib/tar/read_header.c +++ b/lib/tar/read_header.c @@ -189,16 +189,31 @@ static int read_pax_header(int fd, uint64_t entsize, unsigned int *set_by_pax, goto fail_errno; *set_by_pax |= PAX_SLINK_TARGET; } else if (!strncmp(line, "atime=", 6)) { - pax_read_decimal(line + 6, &field); - out->sb.st_atime = field; + if (line[6] == '-') { + pax_read_decimal(line + 7, &field); + out->sb.st_atime = -((int64_t)field); + } else { + pax_read_decimal(line + 6, &field); + out->sb.st_atime = field; + } *set_by_pax |= PAX_ATIME; } else if (!strncmp(line, "mtime=", 6)) { - pax_read_decimal(line + 6, &field); - out->sb.st_mtime = field; + if (line[6] == '-') { + pax_read_decimal(line + 7, &field); + out->sb.st_mtime = -((int64_t)field); + } else { + pax_read_decimal(line + 6, &field); + out->sb.st_mtime = field; + } *set_by_pax |= PAX_MTIME; } else if (!strncmp(line, "ctime=", 6)) { - pax_read_decimal(line + 6, &field); - out->sb.st_ctime = field; + if (line[6] == '-') { + pax_read_decimal(line + 7, &field); + out->sb.st_ctime = -((int64_t)field); + } else { + pax_read_decimal(line + 6, &field); + out->sb.st_ctime = field; + } *set_by_pax |= PAX_CTIME; } } -- cgit v1.2.3