From 33e4c9f64bb0270bb357411a09c4b9cc48eda560 Mon Sep 17 00:00:00 2001 From: magnum Date: Sun, 4 Sep 2016 20:18:01 +0200 Subject: [PATCH] as400-ssha1 format: Add a UTF-8 check in valid() since Convert() depends on correct encoding being used. --- src/as400_ssha1_fmt_plug.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/as400_ssha1_fmt_plug.c b/src/as400_ssha1_fmt_plug.c index ae0740699ef..28fbe2bcaaa 100644 --- a/src/as400_ssha1_fmt_plug.c +++ b/src/as400_ssha1_fmt_plug.c @@ -152,6 +152,10 @@ static int our_valid(char *ciphertext, struct fmt_main *self) if (!strncmp(ciphertext, "$dynamic_1590$", 14)) return pDynamic->methods.valid(ciphertext, pDynamic); + if (options.input_enc == UTF_8 && !valid_utf8((UTF8*)ciphertext)) { + fprintf(stderr, "%s: Input file is not UTF-8. Please use --input-enc to specify a codepage.\n", self->params.label); + error(); + } if (strncmp(ciphertext, FORMAT_TAG, FORMAT_TAG_LEN) != 0) return 0; if (hexlenu(&ciphertext[FORMAT_TAG_LEN], 0) != BINARY_SIZE*2)