diff options
| author | Bruce Evans <bde@FreeBSD.org> | 1999-08-11 08:03:39 +0000 |
|---|---|---|
| committer | Bruce Evans <bde@FreeBSD.org> | 1999-08-11 08:03:39 +0000 |
| commit | 2336ecd56f1b55538ce6a128b301c18c14522189 (patch) | |
| tree | d96c166e2a05a658b0b53ef90db153960820a614 /gnu/usr.bin | |
| parent | 8b67cbda7508da9497c75956a3c07003e6d1a0a0 (diff) | |
Notes
Diffstat (limited to 'gnu/usr.bin')
| -rw-r--r-- | gnu/usr.bin/tar/create.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/gnu/usr.bin/tar/create.c b/gnu/usr.bin/tar/create.c index d01d166f8be0..3f667a79cee3 100644 --- a/gnu/usr.bin/tar/create.c +++ b/gnu/usr.bin/tar/create.c @@ -873,6 +873,8 @@ dump_file (p, curdev, toplevel) #if defined(S_IFBLK) || defined(S_IFCHR) if (type != LF_FIFO) { + char minorbuf[8 + 1]; + if (checked_to_oct ((long) major (hstat.st_rdev), 8, header->header.devmajor)) { @@ -880,13 +882,24 @@ dump_file (p, curdev, toplevel) critical_error = 1; goto badfile; } - if (checked_to_oct ((long) minor (hstat.st_rdev), 8, - header->header.devminor)) + + /* + * Try harder than usual to fit the minor number. to_oct() wastes + * one byte by adding 2 terminating bytes (a space and a NUL) where + * only 1 (either a space or a NUL) is required by POSIX.1. We + * will discard the NUL if that is necessary and sufficient for the + * minor number to fit. This is compatible with tar-1.13. + */ + if (checked_to_oct ((long) minor (hstat.st_rdev), 8 + 1, minorbuf)) { msg ("%s: minor number too large; not dumped", p); critical_error = 1; goto badfile; } + if (minorbuf[0] == ' ') + bcopy(minorbuf + 1, header->header.devminor, 8); + else + bcopy(minorbuf, header->header.devminor, 8); } #endif |
