summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-06-26 12:09:27 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-06-26 16:33:03 +0200
commitd8ee4405393045acfc5dcc9f6f87738dafd7ce21 (patch)
treef3ac5ec350645f663ce943d2d2acca421af8b7c5 /lib
parent1f76cfb6406b4311bf34b48fce475db1b67348a5 (diff)
Add support for negative timestamps in pax header
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib')
-rw-r--r--lib/tar/read_header.c27
1 files 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;
}
}