summaryrefslogtreecommitdiffstats
path: root/dimension
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@gmail.com>2010-04-17 12:27:50 -0400
committerTavian Barnes <tavianator@gmail.com>2010-04-17 12:27:50 -0400
commit8fbe3e7d3325089baf551096983217b4963c789b (patch)
tree8db29e87faf2e3bdf9ac6bc427ab22edb131951d /dimension
parentcf9929b20d4d1230c49dad71f74051067aa4a399 (diff)
downloaddimension-8fbe3e7d3325089baf551096983217b4963c789b.tar.xz
Validate command line arguments.
Diffstat (limited to 'dimension')
-rw-r--r--dimension/main.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/dimension/main.c b/dimension/main.c
index c9bbd37..89e34af 100644
--- a/dimension/main.c
+++ b/dimension/main.c
@@ -30,8 +30,8 @@
static char *output = NULL, *input = NULL;
static bool free_output = false;
-static unsigned int width = 640, height = 480;
-static unsigned int nthreads = 0;
+static int width = 640, height = 480;
+static int nthreads = 0;
static dmnsn_quality quality = DMNSN_RENDER_FULL;
static int tokenize = 0, parse = 0;
@@ -93,8 +93,8 @@ main(int argc, char **argv) {
case 'w':
{
char *endptr;
- width = strtoul(optarg, &endptr, 10);
- if (*endptr != '\0' || endptr == optarg) {
+ width = strtol(optarg, &endptr, 10);
+ if (*endptr != '\0' || endptr == optarg || width <= 0) {
fprintf(stderr, "Invalid argument to --width!\n");
print_usage(stderr, argv[0]);
return EXIT_FAILURE;
@@ -104,8 +104,8 @@ main(int argc, char **argv) {
case 'h':
{
char *endptr;
- height = strtoul(optarg, &endptr, 10);
- if (*endptr != '\0' || endptr == optarg) {
+ height = strtol(optarg, &endptr, 10);
+ if (*endptr != '\0' || endptr == optarg || height <= 0) {
fprintf(stderr, "Invalid argument to --height!\n");
print_usage(stderr, argv[0]);
return EXIT_FAILURE;
@@ -116,8 +116,8 @@ main(int argc, char **argv) {
case DMNSN_OPT_THREADS:
{
char *endptr;
- nthreads = strtoul(optarg, &endptr, 10);
- if (*endptr != '\0' || endptr == optarg) {
+ nthreads = strtol(optarg, &endptr, 10);
+ if (*endptr != '\0' || endptr == optarg || nthreads <= 0) {
fprintf(stderr, "Invalid argument to --threads!\n");
print_usage(stderr, argv[0]);
return EXIT_FAILURE;