From 6d507170c91803095437203a4ef4776a8504fe68 Mon Sep 17 00:00:00 2001
From: magnum <magnum>
Date: Sun, 24 Jul 2011 11:39:09 +0200
Subject: [PATCH 5/5] Fix typo kio8-r -> koi8-r.
 Bail out on unrecognised encoding.
 Fix a compiler warning.

---
 doc/OPTIONS    |    4 ++--
 doc/RULES      |    2 +-
 src/options.c  |   11 +++++++++--
 src/wordlist.c |    2 +-
 4 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/doc/OPTIONS b/doc/OPTIONS
index f2feb31..7b1a07c 100644
--- a/doc/OPTIONS
+++ b/doc/OPTIONS
@@ -40,7 +40,7 @@ These are used to enable the wordlist mode.
 NAME can be:
 	iso-8859-1 (or ansi, or 8859-1)		to handle rules processing with 'high'
 										bit letters.
-  	kio8-r                              rules casing with this encoding.
+  	koi8-r                              rules casing with this encoding.
   	cp1251 (or cp-1251)                 rules casing with this encoding.
 	utf-8 (or utf8)						to enable UTF8 conversions.
 
@@ -54,7 +54,7 @@ not perform conversions, or even consider a word to be 'pure letters', if it
 contains high bit values, even if they are characters, and will not properly
 perform case switching on these characters (such as A or a with a grave or 
 accent).  However, in --encoding=iso-8859-1, john will perform these character
-conversions (also --encoding=kio8-r and --encoding=cp1251 use those character
+conversions (also --encoding=koi8-r and --encoding=cp1251 use those character
 encodings)
 
 --rules[=SECTION]		enable word mangling rules for wordlist mode
diff --git a/doc/RULES b/doc/RULES
index 2f01d6d..86d01c1 100644
--- a/doc/RULES
+++ b/doc/RULES
@@ -64,7 +64,7 @@ than that of "l" (length).
 The complement of a class can be specified by uppercasing its name.  For
 example, "?D" matches everything but digits.
 
-NOTE, if running in --encoding=iso-8859-1 (or ansi/kio8-r/cp1251,etc), then the
+NOTE, if running in --encoding=iso-8859-1 (or ansi/koi8-r/cp1251,etc), then the
 high bit 'letters' are added to the letters in their proper locations. 
 So in iso-8859-1 mode, lower case ?l would be: [a-z]|[\xE0-\xF6]|[\xF8-\xFE]
 while in 'normal' runs, it is only [a-z]
diff --git a/src/options.c b/src/options.c
index f21eca8..18f9da4 100644
--- a/src/options.c
+++ b/src/options.c
@@ -133,7 +133,7 @@ static struct opt_entry opt_list[] = {
 "--wordlist=FILE --stdin   wordlist mode, read words from FILE or stdin\n" \
 "                --pipe    like --stdin, but bulk reads, and allows rules\n" \
 "--encoding=NAME           the input data is in a 'non-standard' character.\n" \
-"                          encoding. NAME = utf-8, iso-8859-1, kio8-r, cp1251\n" \
+"                          encoding. NAME = utf-8, iso-8859-1, koi8-r, cp1251\n" \
 "--rules[=SECTION]         enable word mangling rules for wordlist mode\n" \
 "--incremental[=MODE]      \"incremental\" mode [using section MODE]\n" \
 "--markov[=LEVEL[:opts]]   \"Markov\" mode (see documentation)\n" \
@@ -444,12 +444,19 @@ void opt_init(char *name, int argc, char **argv)
 		// Ok, check a 'few' valid things for utf8
 		if (!strcasecmp(options.encoding, "utf8")||!strcasecmp(options.encoding, "utf-8"))
 			options.utf8 = 1;
+		else
 		if (!strcasecmp(options.encoding, "ansi")||!strcasecmp(options.encoding, "iso-8859-1")||!strcasecmp(options.encoding, "8859-1"))
 			options.iso8859_1 = 1;
-		if (!strcasecmp(options.encoding, "kio8-r")||!strcasecmp(options.encoding, "kio8r"))
+		else
+		if (!strcasecmp(options.encoding, "koi8-r")||!strcasecmp(options.encoding, "koi8r"))
 			options.koi8_r = 1;
+		else
 		if (!strcasecmp(options.encoding, "cp1251")||!strcasecmp(options.encoding, "cp-1251"))
 			options.cp1251 = 1;
+		else {
+			fprintf(stderr, "Unrecognised encoding given.\nSupported encodings: iso-8859-1, koi8-r, cp1251, utf-8\n");
+			error();
+		}
 	}
 
 	rec_argc = argc; rec_argv = argv;
diff --git a/src/wordlist.c b/src/wordlist.c
index 44b5344..bb95daa 100644
--- a/src/wordlist.c
+++ b/src/wordlist.c
@@ -427,7 +427,7 @@ GRAB_NEXT_PIPE_LOAD:;
 					}
 				}
 				sprintf(msg_buf, "- Read block of %d candidate passwords from pipe", nWordFileLines);
-				log_event(msg_buf);
+				log_event("%s", msg_buf);
 			}
 		}
 	}
-- 
1.7.4.1

