diff options
author | kientzle <kientzle@FreeBSD.org> | 2004-07-19 14:54:38 +0000 |
---|---|---|
committer | kientzle <kientzle@FreeBSD.org> | 2004-07-19 14:54:38 +0000 |
commit | adcf12a12b0cb81643c76090b7c3bc8b9c73a7e9 (patch) | |
tree | 21becb9191c7544337796da05f64e680cf51b0ce /usr.bin | |
parent | 4265ad191432ff75ed8c189aa8e4910c6f672e6b (diff) | |
download | FreeBSD-src-adcf12a12b0cb81643c76090b7c3bc8b9c73a7e9.zip FreeBSD-src-adcf12a12b0cb81643c76090b7c3bc8b9c73a7e9.tar.gz |
Guard against argv[0] being NULL.
Thanks to: Tim J Robbins
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/tar/bsdtar.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/usr.bin/tar/bsdtar.c b/usr.bin/tar/bsdtar.c index 87b98320..3a0b001 100644 --- a/usr.bin/tar/bsdtar.c +++ b/usr.bin/tar/bsdtar.c @@ -184,11 +184,15 @@ main(int argc, char **argv) if (bsdtar->user_uid == 0) bsdtar->extract_flags |= ARCHIVE_EXTRACT_OWNER; - bsdtar->progname = strrchr(*argv, '/'); - if (bsdtar->progname != NULL) - bsdtar->progname++; - else - bsdtar->progname = *argv; + if (*argv == NULL) + bsdtar->progname = "bsdtar"; + else { + bsdtar->progname = strrchr(*argv, '/'); + if (bsdtar->progname != NULL) + bsdtar->progname++; + else + bsdtar->progname = *argv; + } /* Rewrite traditional-style tar arguments, if used. */ argv = rewrite_argv(bsdtar, &argc, argv, tar_opts); @@ -500,7 +504,8 @@ rewrite_argv(struct bsdtar *bsdtar, int *argc, char ** src_argv, const char *p; char *src, *dest; - if (src_argv[1] == NULL || src_argv[1][0] == '-') + if (src_argv[0] == NULL || + src_argv[1] == NULL || src_argv[1][0] == '-') return (src_argv); *argc += strlen(src_argv[1]) - 1; |