Fixed a bug in line counter: Conditional jump or move depends on uninitialised value
authorJens Steube <jens.steube@gmail.com>
Wed, 10 Feb 2016 15:56:51 +0000 (16:56 +0100)
committerJens Steube <jens.steube@gmail.com>
Wed, 10 Feb 2016 15:56:51 +0000 (16:56 +0100)
docs/changes.txt
src/oclHashcat.c

index 613fd4c..991840d 100644 (file)
@@ -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:
 
index cf48843..5937e6d 100644 (file)
@@ -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];
     }
   }