summaryrefslogtreecommitdiff
path: root/tar/bsdtar.c
diff options
context:
space:
mode:
authorColin Percival <cperciva@daemonology.net>2011-08-02 04:56:27 -0400
committerColin Percival <cperciva@daemonology.net>2011-08-02 04:56:27 -0400
commit39ed068629d841d15d15abc95eb8e8af6cd66525 (patch)
tree3b549088c0c5b7e563375300a3ab9ba90307c3f4 /tar/bsdtar.c
parent976b0960e67e6ae9d096110157e45d91ad878eb5 (diff)
downloadlibarchive-39ed068629d841d15d15abc95eb8e8af6cd66525.tar.gz
Make sure that the argument to --strip-components is a number. Otherwise
if someone accidentally omits the argument, we'll silently eat the next command line argument. (GNU tar checks this, otherwise I wouldn't bother.) Suggested by: Ralph Corderoy (via Tarsnap) SVN-Revision: 3513
Diffstat (limited to 'tar/bsdtar.c')
-rw-r--r--tar/bsdtar.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/tar/bsdtar.c b/tar/bsdtar.c
index d69ffb34..d508e775 100644
--- a/tar/bsdtar.c
+++ b/tar/bsdtar.c
@@ -493,7 +493,13 @@ main(int argc, char **argv)
bsdtar->extract_flags |= ARCHIVE_EXTRACT_OWNER;
break;
case OPTION_STRIP_COMPONENTS: /* GNU tar 1.15 */
- bsdtar->strip_components = atoi(bsdtar->argument);
+ errno = 0;
+ bsdtar->strip_components = strtol(bsdtar->argument,
+ NULL, 0);
+ if (errno)
+ lafe_errc(1, 0,
+ "Invalid --strip-components argument: %s",
+ bsdtar->argument);
break;
case 'T': /* GNU tar */
bsdtar->names_from_file = bsdtar->argument;