diff options
author | kientzle <kientzle@FreeBSD.org> | 2004-07-17 18:21:00 +0000 |
---|---|---|
committer | kientzle <kientzle@FreeBSD.org> | 2004-07-17 18:21:00 +0000 |
commit | 8b3e9f1e03ec8f63b9dedbc3298d8d7806e4ddc8 (patch) | |
tree | f130ef00731a672251fd700a2e995341e3f4b014 /usr.bin/tar | |
parent | bd6355261fd65fb3d897f468ab35ca671a501796 (diff) | |
download | FreeBSD-src-8b3e9f1e03ec8f63b9dedbc3298d8d7806e4ddc8.zip FreeBSD-src-8b3e9f1e03ec8f63b9dedbc3298d8d7806e4ddc8.tar.gz |
Remove unused user_uname variable.
Add range-checking to argument of -b.
Thanks to: Tim J Robbins
Diffstat (limited to 'usr.bin/tar')
-rw-r--r-- | usr.bin/tar/bsdtar.c | 23 | ||||
-rw-r--r-- | usr.bin/tar/bsdtar.h | 1 |
2 files changed, 8 insertions, 16 deletions
diff --git a/usr.bin/tar/bsdtar.c b/usr.bin/tar/bsdtar.c index aad2ba2..87b98320 100644 --- a/usr.bin/tar/bsdtar.c +++ b/usr.bin/tar/bsdtar.c @@ -51,7 +51,6 @@ struct option { #include <langinfo.h> #endif #include <locale.h> -#include <pwd.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -150,8 +149,7 @@ main(int argc, char **argv) { struct bsdtar *bsdtar, bsdtar_storage; const struct option *option; - struct passwd *pwent; - int opt; + int opt, t; char mode; char possible_help_request; char buff[16]; @@ -172,14 +170,8 @@ main(int argc, char **argv) mode = '\0'; possible_help_request = 0; - /* Look up uid/uname of current user for future reference */ + /* Look up uid of current user for future reference */ bsdtar->user_uid = geteuid(); - bsdtar->user_uname = NULL; - if ((pwent = getpwuid(bsdtar->user_uid))) { - bsdtar->user_uname = (char *)malloc(strlen(pwent->pw_name)+1); - if (bsdtar->user_uname) - strcpy(bsdtar->user_uname, pwent->pw_name); - } /* Default: open tape drive. */ bsdtar->filename = getenv("TAPE"); @@ -211,7 +203,11 @@ main(int argc, char **argv) /* libarchive doesn't need this; just ignore it. */ break; case 'b': /* SUSv2 */ - bsdtar->bytes_per_block = 512 * atoi(optarg); + t = atoi(optarg); + if (t <= 0 || t > 1024) + bsdtar_errc(bsdtar, 1, 0, + "Argument to -b is out of range (1..1024)"); + bsdtar->bytes_per_block = 512 * t; break; case 'C': /* GNU tar */ /* Defer first -C until after -f is opened. */ @@ -414,7 +410,7 @@ main(int argc, char **argv) only_mode(bsdtar, mode, "-o", "xc"); /* Warn about nonsensical -co combination, but ignore it. */ if (mode == 'c') - bsdtar_warnc(bsdtar, 0, "-o is incompatible with -c"); + bsdtar_warnc(bsdtar, 0, "Ignoring nonsensical -o option"); } if (bsdtar->option_no_subdirs) only_mode(bsdtar, mode, "-n", "cru"); @@ -462,9 +458,6 @@ main(int argc, char **argv) break; } - if (bsdtar->user_uname != NULL) - free(bsdtar->user_uname); - cleanup_exclusions(bsdtar); return (bsdtar->return_value); } diff --git a/usr.bin/tar/bsdtar.h b/usr.bin/tar/bsdtar.h index 712a47d..b52e5f1 100644 --- a/usr.bin/tar/bsdtar.h +++ b/usr.bin/tar/bsdtar.h @@ -76,7 +76,6 @@ struct bsdtar { char **argv; size_t gs_width; /* For 'list_item' in read.c */ size_t u_width; /* for 'list_item' in read.c */ - char *user_uname; /* User running this program */ uid_t user_uid; /* UID running this program */ int return_value; /* Value returned by main() */ char warned_lead_slash; /* Already displayed warning */ |