diff options
| author | David Greenman <dg@FreeBSD.org> | 1995-09-18 03:24:07 +0000 |
|---|---|---|
| committer | David Greenman <dg@FreeBSD.org> | 1995-09-18 03:24:07 +0000 |
| commit | 427f53059e0c69de48c14a00079c8499fb401d36 (patch) | |
| tree | 363d931d00433e89c2252838428846dcc4e5701d /gnu/usr.bin | |
| parent | 780b1c87b08e712e108b269e8e1880d70418c971 (diff) | |
Notes
Diffstat (limited to 'gnu/usr.bin')
| -rw-r--r-- | gnu/usr.bin/tar/create.c | 34 | ||||
| -rw-r--r-- | gnu/usr.bin/tar/tar.c | 2 |
2 files changed, 31 insertions, 5 deletions
diff --git a/gnu/usr.bin/tar/create.c b/gnu/usr.bin/tar/create.c index 5d1b71c94b6d..c3be00cb1a1d 100644 --- a/gnu/usr.bin/tar/create.c +++ b/gnu/usr.bin/tar/create.c @@ -875,10 +875,20 @@ dump_file (p, curdev, toplevel) #if defined(S_IFBLK) || defined(S_IFCHR) if (type != LF_FIFO) { - to_oct ((long) major (hstat.st_rdev), 8, - header->header.devmajor); - to_oct ((long) minor (hstat.st_rdev), 8, - header->header.devminor); + if (checked_to_oct ((long) major (hstat.st_rdev), 8, + header->header.devmajor)) + { + msg ("%s: major number too large; not dumped", p); + critical_error = 1; + goto badfile; + } + if (checked_to_oct ((long) minor (hstat.st_rdev), 8, + header->header.devminor)) + { + msg ("%s: minor number too large; not dumped", p); + critical_error = 1; + goto badfile; + } } #endif @@ -1397,6 +1407,22 @@ to_oct (value, digs, where) /* + * Call to_oct (), then return nonzero iff the conversion failed. + */ +int +checked_to_oct (value, digs, where) + register long value; + register int digs; + register char *where; +{ + long from_oct (); + + to_oct (value, digs, where); + return from_oct (digs, where) != value; +} + + +/* * Write the EOT record(s). * We actually zero at least one record, through the end of the block. * Old tar writes garbage after two zeroed records -- and PDtar used to. diff --git a/gnu/usr.bin/tar/tar.c b/gnu/usr.bin/tar/tar.c index 638598667e6b..84e2b94283ce 100644 --- a/gnu/usr.bin/tar/tar.c +++ b/gnu/usr.bin/tar/tar.c @@ -281,7 +281,7 @@ main (argc, argv) } if (f_volno_file) closeout_volume_number (); - exit (errors); + exit (errors ? EX_ARGSBAD : 0); /* FIXME (should be EX_NONDESCRIPT) */ /* NOTREACHED */ } |
