From c79d866e3027140a3612a87fc977b07806b96cdc Mon Sep 17 00:00:00 2001 From: Neale Pickett Date: Thu, 20 Jul 2017 15:27:06 +0000 Subject: [PATCH] Make xor not explode with a single -x argument --- xor.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/xor.c b/xor.c index 9ac7fd3..bd9cfff 100644 --- a/xor.c +++ b/xor.c @@ -1,5 +1,7 @@ /* - * xor filter -- 2012 Zephyr This file is in the public domain. I make no promises about the functionality + * xor filter -- 2017 Neale Pickett + * + * This file is in the public domain. I make no promises about the functionality * of this program. */ @@ -14,16 +16,16 @@ main(int argc, char *argv[]) int base = 0; int arg; - if (argc < 2) { - fprintf(stderr, "Usage: %s [-x] m1 [m2 ...]\n", argv[0]); - return 1; - } - - if (0 == strcmp(argv[1], "-x")) { + if (argv[start] && (0 == strcmp(argv[start], "-x"))) { base = 16; start += 1; } + if (start + 1 > argc) { + fprintf(stderr, "Usage: %s [-x] m1 [m2 ...]\n", argv[0]); + return 1; + } + arg = start; while (1) {