From 8d85b7539d5f14cad9d5b1faa8d1d05ec6287f43 Mon Sep 17 00:00:00 2001 From: Jens Steube Date: Wed, 10 Feb 2016 16:56:51 +0100 Subject: [PATCH] Fixed a bug in line counter: Conditional jump or move depends on uninitialised value --- docs/changes.txt | 10 +++++++--- src/oclHashcat.c | 29 +++++------------------------ 2 files changed, 12 insertions(+), 27 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index 613fd4c..991840d 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -111,15 +111,19 @@ Trac.: 684 Type.: Bug File.: Kernel -Desc.: Fix a bug in the implementation of GOST R 34.11-94, zero length passwords were not cracked +Desc.: Fixed a bug in the implementation of GOST R 34.11-94: Zero length passwords were not cracked Type.: Bug File.: Kernel -Desc.: Fix a bug in rule-engine for NVidia devices, the code for left- and right-shift were switched +Desc.: Fixed a bug in rule-engine for NVidia devices: Code for left- and right-shift were switched Type.: Bug File.: Host -Desc.: Forced default iteration count for -m 2100 = DCC2 hashes to 10240 +Desc.: Fixed a bug in -m 2100 = DCC2: Forced default iteration count for hashes to 10240 + +Type.: Bug +File.: Host +Desc.: Fixed a bug in line counter: Conditional jump or move depends on uninitialised value * changes v2.00 -> v2.01: diff --git a/src/oclHashcat.c b/src/oclHashcat.c index cf48843..5937e6d 100644 --- a/src/oclHashcat.c +++ b/src/oclHashcat.c @@ -1843,40 +1843,21 @@ static uint count_lines (FILE *fd) char *buf = (char *) mymalloc (BUFSIZ + 1); - size_t nread_tmp = 0; - - char *ptr = buf; + char prev = '\n'; while (!feof (fd)) { size_t nread = fread (buf, sizeof (char), BUFSIZ, fd); - nread_tmp = nread; if (nread < 1) continue; - ptr = buf; + size_t i; - do + for (i = 0; i < nread; i++) { - if (*ptr++ == '\n') cnt++; - - } while (nread--); - } - - // special case (if last line did not contain a newline char ... at the very end of the file) + if (prev == '\n') cnt++; - if (nread_tmp > 3) - { - ptr -= 2; - - if (*ptr != '\n') - { - ptr--; - - if (*ptr != '\n') // needed ? different on windows systems? - { - cnt++; - } + prev = buf[i]; } } -- 2.25.1