---
tar.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/tar.c b/tar.c
index d3a9f3b..5f73c26 100644
--- a/tar.c
+++ b/tar.c
_AT_@ -399,10 +399,12 @@ sanitize(struct header *h)
/* Numeric fields can be terminated with spaces instead of
* NULs as per the ustar specification. Patch all of them to
* use NULs so we can perform string operations on them. */
- for (i = 0; i < LEN(fields); i++)
- for (j = 0; j < fields[i].l; j++)
+ for (i = 0; i < LEN(fields); i++){
+ for (j = 0; j < fields[i].l && fields[i].f[j] == ' '; j++);
+ for (; j < fields[i].l; j++)
if (fields[i].f[j] == ' ')
fields[i].f[j] = '\0';
+ }
}
static void
_AT_@ -421,7 +423,8 @@ chktar(struct header *h)
goto bad;
}
memcpy(tmp, h->chksum, sizeof(tmp));
- for (i = 0; i < sizeof(tmp); i++)
+ for (i = 0; i < sizeof(tmp), tmp[i] == ' '; i++);
+ for (; i < sizeof(tmp); i++)
if (tmp[i] == ' ')
tmp[i] = '\0';
s1 = strtol(tmp, &err, 8);
--
2.43.0
Received on Sun Feb 11 2024 - 09:26:14 CET
This archive was generated by hypermail 2.3.0 : Sun Feb 11 2024 - 09:36:32 CET