Initial MESA support, needs more fixes
[hashcat.git] / src / oclHashcat.c
index 292df88..5c0bb56 100644 (file)
@@ -33,7 +33,7 @@ double TARGET_MS_PROFILE[3]     = { 8, 16, 96 };
 #define MARKOV_DISABLE          0
 #define MARKOV_CLASSIC          0
 #define BENCHMARK               0
-#define BENCHMARK_REPEATS       2
+#define BENCHMARK_REPEATS       100
 #define RESTORE                 0
 #define RESTORE_TIMER           60
 #define RESTORE_DISABLE         0
@@ -97,6 +97,7 @@ double TARGET_MS_PROFILE[3]     = { 8, 16, 96 };
 #define HL_MODE_FILE            4
 #define HL_MODE_ARG             5
 
+#define HLFMTS_CNT              11
 #define HLFMT_HASHCAT           0
 #define HLFMT_PWDUMP            1
 #define HLFMT_PASSWD            2
@@ -107,7 +108,17 @@ double TARGET_MS_PROFILE[3]     = { 8, 16, 96 };
 #define HLFMT_NETNTLM2          8
 #define HLFMT_NSLDAP            9
 #define HLFMT_NSLDAPS           10
-#define HLFMTS_CNT              11
+
+#define HLFMT_TEXT_HASHCAT      "native hashcat"
+#define HLFMT_TEXT_PWDUMP       "pwdump"
+#define HLFMT_TEXT_PASSWD       "passwd"
+#define HLFMT_TEXT_SHADOW       "shadow"
+#define HLFMT_TEXT_DCC          "DCC"
+#define HLFMT_TEXT_DCC2         "DCC 2"
+#define HLFMT_TEXT_NETNTLM1     "NetNTLMv1"
+#define HLFMT_TEXT_NETNTLM2     "NetNTLMv2"
+#define HLFMT_TEXT_NSLDAP       "nsldap"
+#define HLFMT_TEXT_NSLDAPS      "nsldaps"
 
 #define ATTACK_MODE_STRAIGHT    0
 #define ATTACK_MODE_COMBI       1
@@ -137,7 +148,7 @@ double TARGET_MS_PROFILE[3]     = { 8, 16, 96 };
 
 #define MAX_DICTSTAT            10000
 
-#define NUM_DEFAULT_BENCHMARK_ALGORITHMS 133
+#define NUM_DEFAULT_BENCHMARK_ALGORITHMS 135
 
 #define global_free(attr)       \
 {                               \
@@ -287,7 +298,9 @@ static uint default_benchmark_algorithms[NUM_DEFAULT_BENCHMARK_ALGORITHMS] =
   6600,
   8200,
   11300,
-  12700
+  12700,
+  13400,
+  125
 };
 
 /**
@@ -379,6 +392,7 @@ const char *USAGE_BIG[] =
   "       --remove                      Enable remove of hash once it is cracked",
   "       --remove-timer=NUM            Update input hash file each NUM seconds",
   "       --potfile-disable             Do not write potfile",
+  "       --potfile-path                Specific path to potfile",
   "       --debug-mode=NUM              Defines the debug mode (hybrid only by using rules), see references below",
   "       --debug-file=FILE             Output file for debugging rules (see also --debug-mode)",
   "       --induction-dir=FOLDER        Specify induction directory to use, default is $session.induct",
@@ -671,6 +685,7 @@ const char *USAGE_BIG[] =
   "   8500 = RACF",
   "   7200 = GRUB 2",
   "   9900 = Radmin2",
+  "    125 = ArubaOS",
   "",
   "[[ Enterprise Application Software (EAS) ]]",
   "",
@@ -731,6 +746,7 @@ const char *USAGE_BIG[] =
   "   8200 = 1Password, cloudkeychain",
   "  11300 = Bitcoin/Litecoin wallet.dat",
   "  12700 = Blockchain, My Wallet",
+  "  13400 = Keepass 1 (AES/Twofish) and Keepass 2 (AES)",
   "",
   NULL
 };
@@ -784,17 +800,11 @@ void status_display_automat ()
 
     if (device_param->skipped) continue;
 
-    u64   speed_cnt  = 0;
-    float speed_ms   = 0;
+    u64    speed_cnt  = 0;
+    double speed_ms   = 0;
 
     for (int i = 0; i < SPEED_CACHE; i++)
     {
-      float rec_ms;
-
-      hc_timer_get (device_param->speed_rec[i], rec_ms);
-
-      if (rec_ms > SPEED_MAXAGE) continue;
-
       speed_cnt  += device_param->speed_cnt[i];
       speed_ms   += device_param->speed_ms[i];
     }
@@ -1055,35 +1065,20 @@ void status_display ()
     {
       wpa_t *wpa = (wpa_t *) data.esalts_buf;
 
-      uint pke[25] = { 0 };
-
-      char *pke_ptr = (char *) pke;
-
-      for (uint i = 0; i < 25; i++)
-      {
-        pke[i] = byte_swap_32 (wpa->pke[i]);
-      }
-
-      char mac1[6] = { 0 };
-      char mac2[6] = { 0 };
-
-      memcpy (mac1, pke_ptr + 23, 6);
-      memcpy (mac2, pke_ptr + 29, 6);
-
       log_info ("Hash.Target....: %s (%02x:%02x:%02x:%02x:%02x:%02x <-> %02x:%02x:%02x:%02x:%02x:%02x)",
                 (char *) data.salts_buf[0].salt_buf,
-                mac1[0] & 0xff,
-                mac1[1] & 0xff,
-                mac1[2] & 0xff,
-                mac1[3] & 0xff,
-                mac1[4] & 0xff,
-                mac1[5] & 0xff,
-                mac2[0] & 0xff,
-                mac2[1] & 0xff,
-                mac2[2] & 0xff,
-                mac2[3] & 0xff,
-                mac2[4] & 0xff,
-                mac2[5] & 0xff);
+                wpa->orig_mac1[0],
+                wpa->orig_mac1[1],
+                wpa->orig_mac1[2],
+                wpa->orig_mac1[3],
+                wpa->orig_mac1[4],
+                wpa->orig_mac1[5],
+                wpa->orig_mac2[0],
+                wpa->orig_mac2[1],
+                wpa->orig_mac2[2],
+                wpa->orig_mac2[3],
+                wpa->orig_mac2[4],
+                wpa->orig_mac2[5]);
     }
     else if (data.hash_mode == 5200)
     {
@@ -1099,7 +1094,7 @@ void status_display ()
     }
     else
     {
-      char out_buf[4096] = { 0 };
+      char out_buf[HCBUFSIZ] = { 0 };
 
       ascii_digest (out_buf, 0, 0);
 
@@ -1119,8 +1114,8 @@ void status_display ()
   {
     if (data.hash_mode == 3000)
     {
-      char out_buf1[4096] = { 0 };
-      char out_buf2[4096] = { 0 };
+      char out_buf1[32] = { 0 };
+      char out_buf2[32] = { 0 };
 
       ascii_digest (out_buf1, 0, 0);
       ascii_digest (out_buf2, 0, 1);
@@ -1139,8 +1134,8 @@ void status_display ()
    * speed new
    */
 
-  u64   speed_cnt[DEVICES_MAX] = { 0 };
-  float speed_ms[DEVICES_MAX]  = { 0 };
+  u64    speed_cnt[DEVICES_MAX] = { 0 };
+  double speed_ms[DEVICES_MAX]  = { 0 };
 
   for (uint device_id = 0; device_id < data.devices_cnt; device_id++)
   {
@@ -1148,25 +1143,11 @@ void status_display ()
 
     if (device_param->skipped) continue;
 
-    // we need to clear values (set to 0) because in case the device does
-    // not get new candidates it idles around but speed display would
-    // show it as working.
-    // if we instantly set it to 0 after reading it happens that the
-    // speed can be shown as zero if the users refreshes too fast.
-    // therefore, we add a timestamp when a stat was recorded and if its
-    // too old we will not use it
-
     speed_cnt[device_id] = 0;
     speed_ms[device_id]  = 0;
 
     for (int i = 0; i < SPEED_CACHE; i++)
     {
-      float rec_ms;
-
-      hc_timer_get (device_param->speed_rec[i], rec_ms);
-
-      if (rec_ms > SPEED_MAXAGE) continue;
-
       speed_cnt[device_id] += device_param->speed_cnt[i];
       speed_ms[device_id]  += device_param->speed_ms[i];
     }
@@ -1216,15 +1197,15 @@ void status_display ()
    * timers
    */
 
-  float ms_running = 0;
+  double ms_running = 0;
 
   hc_timer_get (data.timer_running, ms_running);
 
-  float ms_paused = data.ms_paused;
+  double ms_paused = data.ms_paused;
 
   if (data.devices_status == STATUS_PAUSED)
   {
-    float ms_paused_tmp = 0;
+    double ms_paused_tmp = 0;
 
     hc_timer_get (data.timer_paused, ms_paused_tmp);
 
@@ -1471,7 +1452,7 @@ void status_display ()
       }
     }
 
-    float ms_real = ms_running - ms_paused;
+    double ms_real = ms_running - ms_paused;
 
     float cpt_avg_min  = (float) data.cpt_total / ((ms_real / 1000) / 60);
     float cpt_avg_hour = (float) data.cpt_total / ((ms_real / 1000) / 3600);
@@ -1625,13 +1606,13 @@ void status_display ()
 
 static void status_benchmark ()
 {
-  if (data.devices_status == STATUS_INIT) return;
+  if (data.devices_status == STATUS_INIT)     return;
   if (data.devices_status == STATUS_STARTING) return;
 
   if (data.words_cnt == 0) return;
 
-  u64   speed_cnt[DEVICES_MAX] = { 0 };
-  float speed_ms[DEVICES_MAX]  = { 0 };
+  u64    speed_cnt[DEVICES_MAX] = { 0 };
+  double speed_ms[DEVICES_MAX]  = { 0 };
 
   for (uint device_id = 0; device_id < data.devices_cnt; device_id++)
   {
@@ -1639,17 +1620,8 @@ static void status_benchmark ()
 
     if (device_param->skipped) continue;
 
-    speed_cnt[device_id] = 0;
-    speed_ms[device_id]  = 0;
-
-    for (int i = 0; i < SPEED_CACHE; i++)
-    {
-      speed_cnt[device_id] += device_param->speed_cnt[i];
-      speed_ms[device_id]  += device_param->speed_ms[i];
-    }
-
-    speed_cnt[device_id] /= SPEED_CACHE;
-    speed_ms[device_id]  /= SPEED_CACHE;
+    speed_cnt[device_id] = device_param->speed_cnt[0];
+    speed_ms[device_id]  = device_param->speed_ms[0];
   }
 
   float hashes_all_ms = 0;
@@ -1862,7 +1834,7 @@ static void check_hash (hc_device_param_t *device_param, const uint salt_pos, co
 
   // hash
 
-  char out_buf[4096] = { 0 };
+  char out_buf[HCBUFSIZ] = { 0 };
 
   ascii_digest (out_buf, salt_pos, digest_pos);
 
@@ -2307,7 +2279,7 @@ static void save_hash ()
 
       if (data.hash_mode != 2500)
       {
-        char out_buf[4096] = { 0 };
+        char out_buf[HCBUFSIZ] = { 0 };
 
         if (data.username == 1)
         {
@@ -2464,7 +2436,7 @@ static void run_kernel (const uint kern_run, hc_device_param_t *device_param, co
 
   if (event_update)
   {
-    float exec_time;
+    double exec_time;
 
     hc_timer_get (timer, exec_time);
 
@@ -2702,6 +2674,24 @@ static void choose_kernel (hc_device_param_t *device_param, const uint attack_ex
       if (data.devices_status == STATUS_CRACKED) break;
       if (data.devices_status == STATUS_ABORTED) break;
       if (data.devices_status == STATUS_QUIT)    break;
+
+      /**
+       * speed
+       */
+
+      const float iter_part = (float) (loop_pos + loop_left) / iter;
+
+      const u64 perf_sum_all = pws_cnt * iter_part;
+
+      double speed_ms;
+
+      hc_timer_get (device_param->timer_speed, speed_ms);
+
+      const u32 speed_pos = device_param->speed_pos;
+
+      device_param->speed_cnt[speed_pos] = perf_sum_all;
+
+      device_param->speed_ms[speed_pos] = speed_ms;
     }
 
     if (opts_type & OPTS_TYPE_HOOK23)
@@ -3056,6 +3046,8 @@ static void autotune (hc_device_param_t *device_param)
 
 static void run_cracker (hc_device_param_t *device_param, const uint pws_cnt)
 {
+  char *line_buf = (char *) mymalloc (HCBUFSIZ);
+
   // init speed timer
 
   uint speed_pos = device_param->speed_pos;
@@ -3169,8 +3161,6 @@ static void run_cracker (hc_device_param_t *device_param, const uint pws_cnt)
 
       if (data.attack_mode == ATTACK_MODE_COMBI)
       {
-        char line_buf[BUFSIZ] = { 0 };
-
         uint i = 0;
 
         while (i < innerloop_left)
@@ -3302,9 +3292,34 @@ static void run_cracker (hc_device_param_t *device_param, const uint pws_cnt)
 
       if (data.benchmark == 1)
       {
-        for (u32 i = 0; i < data.benchmark_repeats; i++)
+        double exec_ms_avg_prev = get_avg_exec_time (device_param, EXEC_CACHE);
+
+        // a few caching rounds
+
+        for (u32 i = 0; i < 2; i++)
         {
+          hc_timer_set (&device_param->timer_speed);
+
           choose_kernel (device_param, data.attack_exec, data.attack_mode, data.opts_type, salt_buf, highest_pw_len, pws_cnt);
+
+          double exec_ms_avg = get_avg_exec_time (device_param, EXEC_CACHE);
+
+          exec_ms_avg_prev = exec_ms_avg;
+        }
+
+        // benchmark_repeats became a maximum possible repeats
+
+        for (u32 i = 2; i < data.benchmark_repeats; i++)
+        {
+          hc_timer_set (&device_param->timer_speed);
+
+          choose_kernel (device_param, data.attack_exec, data.attack_mode, data.opts_type, salt_buf, highest_pw_len, pws_cnt);
+
+          double exec_ms_avg = get_avg_exec_time (device_param, EXEC_CACHE);
+
+          if ((exec_ms_avg_prev / exec_ms_avg) < 1.001) break;
+
+          exec_ms_avg_prev = exec_ms_avg;
         }
       }
 
@@ -3330,11 +3345,6 @@ static void run_cracker (hc_device_param_t *device_param, const uint pws_cnt)
 
       u64 perf_sum_all = (u64) pws_cnt * (u64) innerloop_left;
 
-      if (data.benchmark == 1)
-      {
-        perf_sum_all = (perf_sum_all * data.benchmark_repeats) + perf_sum_all;
-      }
-
       hc_thread_mutex_lock (mux_counter);
 
       data.words_progress_done[salt_pos] += perf_sum_all;
@@ -3345,7 +3355,7 @@ static void run_cracker (hc_device_param_t *device_param, const uint pws_cnt)
        * speed
        */
 
-      float speed_ms;
+      double speed_ms;
 
       hc_timer_get (device_param->timer_speed, speed_ms);
 
@@ -3353,12 +3363,12 @@ static void run_cracker (hc_device_param_t *device_param, const uint pws_cnt)
 
       hc_thread_mutex_lock (mux_display);
 
+      // current speed
+
       device_param->speed_cnt[speed_pos] = perf_sum_all;
 
       device_param->speed_ms[speed_pos] = speed_ms;
 
-      device_param->speed_rec[speed_pos] = device_param->timer_speed;
-
       hc_thread_mutex_unlock (mux_display);
 
       speed_pos++;
@@ -3377,6 +3387,8 @@ static void run_cracker (hc_device_param_t *device_param, const uint pws_cnt)
   }
 
   device_param->speed_pos = speed_pos;
+
+  myfree (line_buf);
 }
 
 static void load_segment (wl_data_t *wl_data, FILE *fd)
@@ -4093,11 +4105,11 @@ static void *thread_outfile_remove (void *p)
 
               fseek (fp, out_info[j].seek, SEEK_SET);
 
+              char *line_buf = (char *) mymalloc (HCBUFSIZ);
+
               while (!feof (fp))
               {
-                char line_buf[BUFSIZ] = { 0 };
-
-                char *ptr = fgets (line_buf, BUFSIZ - 1, fp);
+                char *ptr = fgets (line_buf, HCBUFSIZ - 1, fp);
 
                 if (ptr == NULL) break;
 
@@ -4159,28 +4171,14 @@ static void *thread_outfile_remove (void *p)
                             wpa_t *wpas = (wpa_t *) data.esalts_buf;
                             wpa_t *wpa  = &wpas[salt_pos];
 
-                            uint pke[25] = { 0 };
-
-                            char *pke_ptr = (char *) pke;
-
-                            for (uint i = 0; i < 25; i++)
-                            {
-                              pke[i] = byte_swap_32 (wpa->pke[i]);
-                            }
-
-                            u8 mac1[6] = { 0 };
-                            u8 mac2[6] = { 0 };
-
-                            memcpy (mac1, pke_ptr + 23, 6);
-                            memcpy (mac2, pke_ptr + 29, 6);
-
                             // compare hex string(s) vs binary MAC address(es)
 
                             for (uint i = 0, j = 0; i < 6; i++, j += 2)
                             {
-                              if (mac1[i] != hex_to_u8 ((const u8 *) &mac1_pos[j]))
+                              if (wpa->orig_mac1[i] != hex_to_u8 ((const u8 *) &mac1_pos[j]))
                               {
                                 cracked = 0;
+
                                 break;
                               }
                             }
@@ -4190,9 +4188,10 @@ static void *thread_outfile_remove (void *p)
 
                             for (uint i = 0, j = 0; i < 6; i++, j += 2)
                             {
-                              if (mac2[i] != hex_to_u8 ((const u8 *) &mac2_pos[j]))
+                              if (wpa->orig_mac2[i] != hex_to_u8 ((const u8 *) &mac2_pos[j]))
                               {
                                 cracked = 0;
+
                                 break;
                               }
                             }
@@ -4242,6 +4241,8 @@ static void *thread_outfile_remove (void *p)
                 if (data.devices_status == STATUS_CRACKED) break;
               }
 
+              myfree (line_buf);
+
               out_info[j].seek = ftell (fp);
 
               //hc_thread_mutex_unlock (mux_display);
@@ -4351,6 +4352,8 @@ static void *thread_calc_stdin (void *p)
 
   autotune (device_param);
 
+  char *buf = (char *) mymalloc (HCBUFSIZ);
+
   const uint attack_kern = data.attack_kern;
 
   const uint kernel_power = device_param->kernel_power;
@@ -4370,9 +4373,7 @@ static void *thread_calc_stdin (void *p)
 
     while (words_cur < kernel_power)
     {
-      char buf[BUFSIZ] = { 0 };
-
-      char *line_buf = fgets (buf, sizeof (buf), stdin);
+      char *line_buf = fgets (buf, HCBUFSIZ - 1, stdin);
 
       if (line_buf == NULL) break;
 
@@ -4483,6 +4484,8 @@ static void *thread_calc_stdin (void *p)
   device_param->kernel_accel = 0;
   device_param->kernel_loops = 0;
 
+  myfree (buf);
+
   return NULL;
 }
 
@@ -4863,7 +4866,7 @@ static void weak_hash_check (hc_device_param_t *device_param, const uint salt_po
 
 // hlfmt hashcat
 
-static void hlfmt_hash_hashcat (char line_buf[BUFSIZ], int line_len, char **hashbuf_pos, int *hashbuf_len)
+static void hlfmt_hash_hashcat (char *line_buf, int line_len, char **hashbuf_pos, int *hashbuf_len)
 {
   if (data.username == 0)
   {
@@ -4892,7 +4895,7 @@ static void hlfmt_hash_hashcat (char line_buf[BUFSIZ], int line_len, char **hash
   }
 }
 
-static void hlfmt_user_hashcat (char line_buf[BUFSIZ], int line_len, char **userbuf_pos, int *userbuf_len)
+static void hlfmt_user_hashcat (char *line_buf, int line_len, char **userbuf_pos, int *userbuf_len)
 {
   char *pos = NULL;
   int   len = 0;
@@ -4922,7 +4925,7 @@ static void hlfmt_user_hashcat (char line_buf[BUFSIZ], int line_len, char **user
 
 // hlfmt pwdump
 
-static int hlfmt_detect_pwdump (char line_buf[BUFSIZ], int line_len)
+static int hlfmt_detect_pwdump (char *line_buf, int line_len)
 {
   int sep_cnt = 0;
 
@@ -4947,7 +4950,7 @@ static int hlfmt_detect_pwdump (char line_buf[BUFSIZ], int line_len)
   return 0;
 }
 
-static void hlfmt_hash_pwdump (char line_buf[BUFSIZ], int line_len, char **hashbuf_pos, int *hashbuf_len)
+static void hlfmt_hash_pwdump (char *line_buf, int line_len, char **hashbuf_pos, int *hashbuf_len)
 {
   char *pos = NULL;
   int   len = 0;
@@ -4987,7 +4990,7 @@ static void hlfmt_hash_pwdump (char line_buf[BUFSIZ], int line_len, char **hashb
   *hashbuf_len = len;
 }
 
-static void hlfmt_user_pwdump (char line_buf[BUFSIZ], int line_len, char **userbuf_pos, int *userbuf_len)
+static void hlfmt_user_pwdump (char *line_buf, int line_len, char **userbuf_pos, int *userbuf_len)
 {
   char *pos = NULL;
   int   len = 0;
@@ -5017,7 +5020,7 @@ static void hlfmt_user_pwdump (char line_buf[BUFSIZ], int line_len, char **userb
 
 // hlfmt passwd
 
-static int hlfmt_detect_passwd (char line_buf[BUFSIZ], int line_len)
+static int hlfmt_detect_passwd (char *line_buf, int line_len)
 {
   int sep_cnt = 0;
 
@@ -5042,7 +5045,7 @@ static int hlfmt_detect_passwd (char line_buf[BUFSIZ], int line_len)
   return 0;
 }
 
-static void hlfmt_hash_passwd (char line_buf[BUFSIZ], int line_len, char **hashbuf_pos, int *hashbuf_len)
+static void hlfmt_hash_passwd (char *line_buf, int line_len, char **hashbuf_pos, int *hashbuf_len)
 {
   char *pos = NULL;
   int   len = 0;
@@ -5070,7 +5073,7 @@ static void hlfmt_hash_passwd (char line_buf[BUFSIZ], int line_len, char **hashb
   *hashbuf_len = len;
 }
 
-static void hlfmt_user_passwd (char line_buf[BUFSIZ], int line_len, char **userbuf_pos, int *userbuf_len)
+static void hlfmt_user_passwd (char *line_buf, int line_len, char **userbuf_pos, int *userbuf_len)
 {
   char *pos = NULL;
   int   len = 0;
@@ -5100,7 +5103,7 @@ static void hlfmt_user_passwd (char line_buf[BUFSIZ], int line_len, char **userb
 
 // hlfmt shadow
 
-static int hlfmt_detect_shadow (char line_buf[BUFSIZ], int line_len)
+static int hlfmt_detect_shadow (char *line_buf, int line_len)
 {
   int sep_cnt = 0;
 
@@ -5114,19 +5117,19 @@ static int hlfmt_detect_shadow (char line_buf[BUFSIZ], int line_len)
   return 0;
 }
 
-static void hlfmt_hash_shadow (char line_buf[BUFSIZ], int line_len, char **hashbuf_pos, int *hashbuf_len)
+static void hlfmt_hash_shadow (char *line_buf, int line_len, char **hashbuf_pos, int *hashbuf_len)
 {
   hlfmt_hash_passwd (line_buf, line_len, hashbuf_pos, hashbuf_len);
 }
 
-static void hlfmt_user_shadow (char line_buf[BUFSIZ], int line_len, char **userbuf_pos, int *userbuf_len)
+static void hlfmt_user_shadow (char *line_buf, int line_len, char **userbuf_pos, int *userbuf_len)
 {
   hlfmt_user_passwd (line_buf, line_len, userbuf_pos, userbuf_len);
 }
 
 // hlfmt main
 
-static void hlfmt_hash (uint hashfile_format, char line_buf[BUFSIZ], int line_len, char **hashbuf_pos, int *hashbuf_len)
+static void hlfmt_hash (uint hashfile_format, char *line_buf, int line_len, char **hashbuf_pos, int *hashbuf_len)
 {
   switch (hashfile_format)
   {
@@ -5137,7 +5140,7 @@ static void hlfmt_hash (uint hashfile_format, char line_buf[BUFSIZ], int line_le
   }
 }
 
-static void hlfmt_user (uint hashfile_format, char line_buf[BUFSIZ], int line_len, char **userbuf_pos, int *userbuf_len)
+static void hlfmt_user (uint hashfile_format, char *line_buf, int line_len, char **userbuf_pos, int *userbuf_len)
 {
   switch (hashfile_format)
   {
@@ -5148,6 +5151,25 @@ static void hlfmt_user (uint hashfile_format, char line_buf[BUFSIZ], int line_le
   }
 }
 
+char *strhlfmt (const uint hashfile_format)
+{
+  switch (hashfile_format)
+  {
+    case HLFMT_HASHCAT:  return ((char *) HLFMT_TEXT_HASHCAT);  break;
+    case HLFMT_PWDUMP:   return ((char *) HLFMT_TEXT_PWDUMP);   break;
+    case HLFMT_PASSWD:   return ((char *) HLFMT_TEXT_PASSWD);   break;
+    case HLFMT_SHADOW:   return ((char *) HLFMT_TEXT_SHADOW);   break;
+    case HLFMT_DCC:      return ((char *) HLFMT_TEXT_DCC);      break;
+    case HLFMT_DCC2:     return ((char *) HLFMT_TEXT_DCC2);     break;
+    case HLFMT_NETNTLM1: return ((char *) HLFMT_TEXT_NETNTLM1); break;
+    case HLFMT_NETNTLM2: return ((char *) HLFMT_TEXT_NETNTLM2); break;
+    case HLFMT_NSLDAP:   return ((char *) HLFMT_TEXT_NSLDAP);   break;
+    case HLFMT_NSLDAPS:  return ((char *) HLFMT_TEXT_NSLDAPS);  break;
+  }
+
+  return ((char *) "Unknown");
+}
+
 static uint hlfmt_detect (FILE *fp, uint max_check)
 {
   // Exception: those formats are wrongly detected as HLFMT_SHADOW, prevent it
@@ -5159,10 +5181,10 @@ static uint hlfmt_detect (FILE *fp, uint max_check)
 
   uint num_check = 0;
 
+  char *line_buf = (char *) mymalloc (HCBUFSIZ);
+
   while (!feof (fp))
   {
-    char line_buf[BUFSIZ] = { 0 };
-
     int line_len = fgetl (fp, line_buf);
 
     if (line_len == 0) continue;
@@ -5176,6 +5198,8 @@ static uint hlfmt_detect (FILE *fp, uint max_check)
     num_check++;
   }
 
+  myfree (line_buf);
+
   uint hashlist_format = HLFMT_HASHCAT;
 
   for (int i = 1; i < HLFMTS_CNT; i++)
@@ -5284,6 +5308,9 @@ int main (int argc, char **argv)
   if (getenv ("GPU_USE_SYNC_OBJECTS") == NULL)
     putenv ((char *) "GPU_USE_SYNC_OBJECTS=1");
 
+  if (getenv ("CUDA_CACHE_DISABLE") == NULL)
+    putenv ((char *) "CUDA_CACHE_DISABLE=1");
+
   /**
    * Real init
    */
@@ -5322,6 +5349,7 @@ int main (int argc, char **argv)
   u64   limit             = LIMIT;
   uint  keyspace          = KEYSPACE;
   uint  potfile_disable   = POTFILE_DISABLE;
+  char *potfile_path      = NULL;
   uint  debug_mode        = DEBUG_MODE;
   char *debug_file        = NULL;
   char *induction_dir     = NULL;
@@ -5400,6 +5428,7 @@ int main (int argc, char **argv)
   #define IDX_LIMIT             'l'
   #define IDX_KEYSPACE          0xff35
   #define IDX_POTFILE_DISABLE   0xff06
+  #define IDX_POTFILE_PATH      0xffe0
   #define IDX_DEBUG_MODE        0xff43
   #define IDX_DEBUG_FILE        0xff44
   #define IDX_INDUCTION_DIR     0xff46
@@ -5480,6 +5509,7 @@ int main (int argc, char **argv)
     {"limit",             required_argument, 0, IDX_LIMIT},
     {"keyspace",          no_argument,       0, IDX_KEYSPACE},
     {"potfile-disable",   no_argument,       0, IDX_POTFILE_DISABLE},
+    {"potfile-path",      required_argument, 0, IDX_POTFILE_PATH},
     {"debug-mode",        required_argument, 0, IDX_DEBUG_MODE},
     {"debug-file",        required_argument, 0, IDX_DEBUG_FILE},
     {"induction-dir",     required_argument, 0, IDX_INDUCTION_DIR},
@@ -5786,6 +5816,7 @@ int main (int argc, char **argv)
       case IDX_REMOVE_TIMER:      remove_timer      = atoi (optarg);
                                   remove_timer_chgd = 1;               break;
       case IDX_POTFILE_DISABLE:   potfile_disable   = 1;               break;
+      case IDX_POTFILE_PATH:      potfile_path      = optarg;          break;
       case IDX_DEBUG_MODE:        debug_mode        = atoi (optarg);   break;
       case IDX_DEBUG_FILE:        debug_file        = optarg;          break;
       case IDX_INDUCTION_DIR:     induction_dir     = optarg;          break;
@@ -5940,7 +5971,7 @@ int main (int argc, char **argv)
     return (-1);
   }
 
-  if (hash_mode_chgd && hash_mode > 13300) // just added to remove compiler warnings for hash_mode_chgd
+  if (hash_mode_chgd && hash_mode > 13400) // just added to remove compiler warnings for hash_mode_chgd
   {
     log_error ("ERROR: Invalid hash-type specified");
 
@@ -6643,6 +6674,7 @@ int main (int argc, char **argv)
   logfile_top_uint   (outfile_check_timer);
   logfile_top_uint   (outfile_format);
   logfile_top_uint   (potfile_disable);
+  logfile_top_string (potfile_path);
   #if defined(HAVE_HWMON) && defined(HAVE_ADL)
   logfile_top_uint   (powertune_enable);
   #endif
@@ -7303,6 +7335,30 @@ int main (int argc, char **argv)
                    dgst_pos3   = 1;
                    break;
 
+      case   125:  hash_type   = HASH_TYPE_SHA1;
+                   salt_type   = SALT_TYPE_EMBEDDED;
+                   attack_exec = ATTACK_EXEC_INSIDE_KERNEL;
+                   opts_type   = OPTS_TYPE_PT_GENERATE_BE
+                               | OPTS_TYPE_PT_ADD80
+                               | OPTS_TYPE_PT_ADDBITS15
+                               | OPTS_TYPE_ST_HEX;
+                   kern_type   = KERN_TYPE_SHA1_SLTPW;
+                   dgst_size   = DGST_SIZE_4_5;
+                   parse_func  = arubaos_parse_hash;
+                   sort_by_digest = sort_by_digest_4_5;
+                   opti_type   = OPTI_TYPE_ZERO_BYTE
+                               | OPTI_TYPE_PRECOMPUTE_INIT
+                               | OPTI_TYPE_PRECOMPUTE_MERKLE
+                               | OPTI_TYPE_EARLY_SKIP
+                               | OPTI_TYPE_NOT_ITERATED
+                               | OPTI_TYPE_PREPENDED_SALT
+                               | OPTI_TYPE_RAW_HASH;
+                   dgst_pos0   = 3;
+                   dgst_pos1   = 4;
+                   dgst_pos2   = 2;
+                   dgst_pos3   = 1;
+                   break;
+
       case   130:  hash_type   = HASH_TYPE_SHA1;
                    salt_type   = SALT_TYPE_INTERN;
                    attack_exec = ATTACK_EXEC_INSIDE_KERNEL;
@@ -9260,7 +9316,7 @@ int main (int argc, char **argv)
       case  8300:  hash_type   = HASH_TYPE_SHA1;
                    salt_type   = SALT_TYPE_EMBEDDED;
                    attack_exec = ATTACK_EXEC_INSIDE_KERNEL;
-                   opts_type   = OPTS_TYPE_PT_GENERATE_LE
+                   opts_type   = OPTS_TYPE_PT_GENERATE_BE
                                | OPTS_TYPE_ST_HEX
                                | OPTS_TYPE_ST_ADD80;
                    kern_type   = KERN_TYPE_NSEC3;
@@ -10226,6 +10282,21 @@ int main (int argc, char **argv)
                    dgst_pos3   = 2;
                    break;
 
+      case 13400:  hash_type   = HASH_TYPE_AES;
+                   salt_type   = SALT_TYPE_EMBEDDED;
+                   attack_exec = ATTACK_EXEC_OUTSIDE_KERNEL;
+                   opts_type   = OPTS_TYPE_PT_GENERATE_LE;
+                   kern_type   = KERN_TYPE_KEEPASS;
+                   dgst_size   = DGST_SIZE_4_4;
+                   parse_func  = keepass_parse_hash;
+                   sort_by_digest = sort_by_digest_4_4;
+                   opti_type   = OPTI_TYPE_ZERO_BYTE;
+                   dgst_pos0   = 0;
+                   dgst_pos1   = 1;
+                   dgst_pos2   = 2;
+                   dgst_pos3   = 3;
+                   break;
+
       default:     usage_mini_print (PROGNAME); return (-1);
     }
 
@@ -10330,6 +10401,7 @@ int main (int argc, char **argv)
       case 12100:  esalt_size = sizeof (pbkdf2_sha512_t); break;
       case 13000:  esalt_size = sizeof (rar5_t);          break;
       case 13100:  esalt_size = sizeof (krb5tgs_t);       break;
+      case 13400:  esalt_size = sizeof (keepass_t);       break;
     }
 
     data.esalt_size = esalt_size;
@@ -10371,7 +10443,7 @@ int main (int argc, char **argv)
 
     if (keyspace == 0)
     {
-      snprintf (dictstat, sizeof (dictstat) - 1, "%s/hashcat.dictstat", profile_dir);
+      snprintf (dictstat, sizeof (dictstat) - 1, "%s/%s", profile_dir, DICTSTAT_FILENAME);
 
       dictstat_fp = fopen (dictstat, "rb");
 
@@ -10427,7 +10499,14 @@ int main (int argc, char **argv)
 
     char potfile[256] = { 0 };
 
-    snprintf (potfile, sizeof (potfile) - 1, "%s/%s.pot", session_dir, session);
+    if (potfile_path == NULL)
+    {
+      snprintf (potfile, sizeof (potfile) - 1, "%s/%s", profile_dir, POTFILE_FILENAME);
+    }
+    else
+    {
+      strncpy (potfile, potfile_path, sizeof (potfile) - 1);
+    }
 
     data.pot_fp = NULL;
 
@@ -10497,12 +10576,12 @@ int main (int argc, char **argv)
 
       uint line_num = 0;
 
+      char *line_buf = (char *) mymalloc (HCBUFSIZ);
+
       while (!feof (pot_fp))
       {
         line_num++;
 
-        char line_buf[BUFSIZ] = { 0 };
-
         int line_len = fgetl (pot_fp, line_buf);
 
         if (line_len == 0) continue;
@@ -10612,6 +10691,8 @@ int main (int argc, char **argv)
         pot_cnt++;
       }
 
+      myfree (line_buf);
+
       fclose (pot_fp);
 
       SUPPRESS_OUTPUT = 0;
@@ -10628,6 +10709,8 @@ int main (int argc, char **argv)
 
     switch (hash_mode)
     {
+      case   125: if (pw_max > 32) pw_max = 32;
+                  break;
       case   400: if (pw_max > 40) pw_max = 40;
                   break;
       case   500: if (pw_max > 16) pw_max = 16;
@@ -10914,7 +10997,16 @@ int main (int argc, char **argv)
 
         hlfmt_hash (hashlist_format, input_buf, input_len, &hash_buf, &hash_len);
 
-        if (hash_len)
+        bool hash_fmt_error = 0;
+
+        if (hash_len < 1)     hash_fmt_error = 1;
+        if (hash_buf == NULL) hash_fmt_error = 1;
+
+        if (hash_fmt_error)
+        {
+          log_info ("WARNING: failed to parse hashes using the '%s' format", strhlfmt (hashlist_format));
+        }
+        else
         {
           if (opts_type & OPTS_TYPE_HASH_COPY)
           {
@@ -10998,16 +11090,23 @@ int main (int argc, char **argv)
 
                 wpa_t *wpa = (wpa_t *) hashes_buf[hashes_cnt].esalt;
 
-                u8 *pke_ptr = (u8 *) wpa->pke;
-
                 // do the appending task
 
                 snprintf (salt_ptr + cur_pos,
                           rem_len,
                           ":%02x%02x%02x%02x%02x%02x:%02x%02x%02x%02x%02x%02x",
-                          pke_ptr[20], pke_ptr[27], pke_ptr[26], pke_ptr[25], pke_ptr[24], pke_ptr[31],  // MAC1
-                          pke_ptr[30], pke_ptr[29], pke_ptr[28], pke_ptr[35], pke_ptr[34], pke_ptr[33]); // MAC2
-
+                          wpa->orig_mac1[0],
+                          wpa->orig_mac1[1],
+                          wpa->orig_mac1[2],
+                          wpa->orig_mac1[3],
+                          wpa->orig_mac1[4],
+                          wpa->orig_mac1[5],
+                          wpa->orig_mac2[0],
+                          wpa->orig_mac2[1],
+                          wpa->orig_mac2[2],
+                          wpa->orig_mac2[3],
+                          wpa->orig_mac2[4],
+                          wpa->orig_mac2[5]);
 
                 // memset () the remaining part of the salt
 
@@ -11127,12 +11226,12 @@ int main (int argc, char **argv)
 
         uint line_num = 0;
 
+        char *line_buf = (char *) mymalloc (HCBUFSIZ);
+
         while (!feof (fp))
         {
           line_num++;
 
-          char line_buf[BUFSIZ] = { 0 };
-
           int line_len = fgetl (fp, line_buf);
 
           if (line_len == 0) continue;
@@ -11142,7 +11241,17 @@ int main (int argc, char **argv)
 
           hlfmt_hash (hashlist_format, line_buf, line_len, &hash_buf, &hash_len);
 
-          if (hash_len < 1) continue;
+          bool hash_fmt_error = 0;
+
+          if (hash_len < 1)     hash_fmt_error = 1;
+          if (hash_buf == NULL) hash_fmt_error = 1;
+
+          if (hash_fmt_error)
+          {
+            log_info ("WARNING: failed to parse hashes using the '%s' format", strhlfmt (hashlist_format));
+
+            continue;
+          }
 
           if (username)
           {
@@ -11260,6 +11369,8 @@ int main (int argc, char **argv)
           }
         }
 
+        myfree (line_buf);
+
         fclose (fp);
 
         if (data.quiet == 0) log_info_nn ("Parsed Hashes: %u/%u (%0.2f%%)", hashes_avail, hashes_avail, 100.00);
@@ -11277,7 +11388,8 @@ int main (int argc, char **argv)
 
         switch (hash_mode)
         {
-          case  1500: hashes_buf[0].salt->salt_len = 2;
+          case  1500: hashes_buf[0].salt->salt_len    = 2;
+                      hashes_buf[0].salt->salt_buf[0] = 388; // pure magic
                       break;
           case  1731: hashes_buf[0].salt->salt_len = 4;
                       break;
@@ -11393,6 +11505,8 @@ int main (int argc, char **argv)
                       ((seven_zip_t *) hashes_buf[0].esalt)->data_len    = 112;
                       ((seven_zip_t *) hashes_buf[0].esalt)->unpack_size = 112;
                       break;
+          case 13400: ((keepass_t *) hashes_buf[0].esalt)->version       = 2;
+                      break;
         }
       }
 
@@ -11566,6 +11680,8 @@ int main (int argc, char **argv)
                      break;
         case 13200:  hashes_buf[0].salt->salt_iter = ROUNDS_AXCRYPT;
                      break;
+        case 13400:  hashes_buf[0].salt->salt_iter = ROUNDS_KEEPASS;
+                     break;
       }
 
       hashes_cnt = 1;
@@ -11775,11 +11891,17 @@ int main (int argc, char **argv)
 
         if (fp != NULL)
         {
+          char *line_buf = (char *) mymalloc (HCBUFSIZ);
+
+          // to be safe work with a copy (because of line_len loop, i etc)
+          // moved up here because it's easier to handle continue case
+          // it's just 64kb
+
+          char *line_buf_cpy = (char *) mymalloc (HCBUFSIZ);
+
           while (!feof (fp))
           {
-            char line_buf[BUFSIZ] =  { 0 };
-
-            char *ptr = fgets (line_buf, BUFSIZ - 1, fp);
+            char *ptr = fgets (line_buf, HCBUFSIZ - 1, fp);
 
             if (ptr == NULL) break;
 
@@ -11819,10 +11941,6 @@ int main (int argc, char **argv)
                   // here we have in line_buf: ESSID:MAC1:MAC2   (without the plain)
                   // manipulate salt_buf
 
-                  // to be safe work with a copy (because of line_len loop, i etc)
-
-                  char line_buf_cpy[BUFSIZ] = { 0 };
-
                   memcpy (line_buf_cpy, line_buf, i);
 
                   char *mac2_pos = strrchr (line_buf_cpy, ':');
@@ -11856,28 +11974,14 @@ int main (int argc, char **argv)
                   {
                     wpa_t *wpa = (wpa_t *) found->esalt;
 
-                    uint pke[25] = { 0 };
-
-                    char *pke_ptr = (char *) pke;
-
-                    for (uint i = 0; i < 25; i++)
-                    {
-                      pke[i] = byte_swap_32 (wpa->pke[i]);
-                    }
-
-                    u8 mac1[6] = { 0 };
-                    u8 mac2[6] = { 0 };
-
-                    memcpy (mac1, pke_ptr + 23, 6);
-                    memcpy (mac2, pke_ptr + 29, 6);
-
                     // compare hex string(s) vs binary MAC address(es)
 
                     for (uint i = 0, j = 0; i < 6; i++, j += 2)
                     {
-                      if (mac1[i] != hex_to_u8 ((const u8 *) &mac1_pos[j]))
+                      if (wpa->orig_mac1[i] != hex_to_u8 ((const u8 *) &mac1_pos[j]))
                       {
                         found = NULL;
+
                         break;
                       }
                     }
@@ -11887,9 +11991,10 @@ int main (int argc, char **argv)
 
                     for (uint i = 0, j = 0; i < 6; i++, j += 2)
                     {
-                      if (mac2[i] != hex_to_u8 ((const u8 *) &mac2_pos[j]))
+                      if (wpa->orig_mac2[i] != hex_to_u8 ((const u8 *) &mac2_pos[j]))
                       {
                         found = NULL;
+
                         break;
                       }
                     }
@@ -11925,6 +12030,10 @@ int main (int argc, char **argv)
             }
           }
 
+          myfree (line_buf_cpy);
+
+          myfree (line_buf);
+
           fclose (fp);
         }
       }
@@ -12300,7 +12409,7 @@ int main (int argc, char **argv)
       all_kernel_rules_buf = (kernel_rule_t **) mycalloc (rp_files_cnt, sizeof (kernel_rule_t *));
     }
 
-    char rule_buf[BUFSIZ] = { 0 };
+    char *rule_buf = (char *) mymalloc (HCBUFSIZ);
 
     int rule_len = 0;
 
@@ -12330,7 +12439,7 @@ int main (int argc, char **argv)
 
       while (!feof (fp))
       {
-        memset (rule_buf, 0, BUFSIZ);
+        memset (rule_buf, 0, HCBUFSIZ);
 
         rule_len = fgetl (fp, rule_buf);
 
@@ -12458,7 +12567,7 @@ int main (int argc, char **argv)
             kernel_rules_avail += INCR_RULES;
           }
 
-          memset (rule_buf, 0, BLOCK_SIZE);
+          memset (rule_buf, 0, HCBUFSIZ);
 
           rule_len = (int) generate_random_rule (rule_buf, rp_gen_func_min, rp_gen_func_max);
 
@@ -12469,6 +12578,8 @@ int main (int argc, char **argv)
       }
     }
 
+    myfree (rule_buf);
+
     /**
      * generate NOP rules
      */
@@ -12753,13 +12864,20 @@ int main (int argc, char **argv)
         {
           if (vendor_id == VENDOR_ID_AMD)
           {
-            cl_uint device_processor_cores = 0;
+            if (strstr (device_version, "MESA"))
+            {
+              // MESA stuff
+            }
+            else
+            {
+              cl_uint device_processor_cores = 0;
 
-            #define CL_DEVICE_WAVEFRONT_WIDTH_AMD               0x4043
+              #define CL_DEVICE_WAVEFRONT_WIDTH_AMD               0x4043
 
-            hc_clGetDeviceInfo (data.ocl, device_param->device, CL_DEVICE_WAVEFRONT_WIDTH_AMD, sizeof (device_processor_cores), &device_processor_cores, NULL);
+              hc_clGetDeviceInfo (data.ocl, device_param->device, CL_DEVICE_WAVEFRONT_WIDTH_AMD, sizeof (device_processor_cores), &device_processor_cores, NULL);
 
-            device_param->device_processor_cores = device_processor_cores;
+              device_param->device_processor_cores = device_processor_cores;
+            }
           }
           else if (vendor_id == VENDOR_ID_NV)
           {
@@ -12851,50 +12969,57 @@ int main (int argc, char **argv)
             }
             else if (vendor_id == VENDOR_ID_AMD)
             {
-              int catalyst_check = (force == 1) ? 0 : 1;
-
-              int catalyst_warn = 0;
+              if (strstr (device_version, "MESA"))
+              {
+                // MESA stuff
+              }
+              else
+              {
+                int catalyst_check = (force == 1) ? 0 : 1;
 
-              int catalyst_broken = 0;
+                int catalyst_warn = 0;
 
-              if (catalyst_check == 1)
-              {
-                catalyst_warn = 1;
+                int catalyst_broken = 0;
 
-                // v14.9 and higher
-                if (atoi (device_param->driver_version) >= 1573)
+                if (catalyst_check == 1)
                 {
-                  catalyst_warn = 0;
-                }
+                  catalyst_warn = 1;
 
-                catalyst_check = 0;
-              }
+                  // v14.9 and higher
+                  if (atoi (device_param->driver_version) >= 1573)
+                  {
+                    catalyst_warn = 0;
+                  }
 
-              if (catalyst_broken == 1)
-              {
-                log_info ("");
-                log_info ("ATTENTION! The installed catalyst driver in your system is known to be broken!");
-                log_info ("It will pass over cracked hashes and does not report them as cracked");
-                log_info ("You are STRONGLY encouraged not to use it");
-                log_info ("You can use --force to override this but do not post error reports if you do so");
-                log_info ("");
+                  catalyst_check = 0;
+                }
 
-                return (-1);
-              }
+                if (catalyst_broken == 1)
+                {
+                  log_info ("");
+                  log_info ("ATTENTION! The installed catalyst driver in your system is known to be broken!");
+                  log_info ("It will pass over cracked hashes and does not report them as cracked");
+                  log_info ("You are STRONGLY encouraged not to use it");
+                  log_info ("You can use --force to override this but do not post error reports if you do so");
+                  log_info ("");
 
-              if (catalyst_warn == 1)
-              {
-                log_info ("");
-                log_info ("ATTENTION! Unsupported or incorrect installed catalyst driver detected!");
-                log_info ("You are STRONGLY encouraged to use the official supported catalyst driver for good reasons");
-                log_info ("See oclHashcat's homepage for official supported catalyst drivers");
-                #ifdef _WIN
-                log_info ("Also see: http://hashcat.net/wiki/doku.php?id=upgrading_amd_drivers_how_to");
-                #endif
-                log_info ("You can use --force to override this but do not post error reports if you do so");
-                log_info ("");
+                  return (-1);
+                }
 
-                return (-1);
+                if (catalyst_warn == 1)
+                {
+                  log_info ("");
+                  log_info ("ATTENTION! Unsupported or incorrect installed catalyst driver detected!");
+                  log_info ("You are STRONGLY encouraged to use the official supported catalyst driver for good reasons");
+                  log_info ("See oclHashcat's homepage for official supported catalyst drivers");
+                  #ifdef _WIN
+                  log_info ("Also see: http://hashcat.net/wiki/doku.php?id=upgrading_amd_drivers_how_to");
+                  #endif
+                  log_info ("You can use --force to override this but do not post error reports if you do so");
+                  log_info ("");
+
+                  return (-1);
+                }
               }
             }
           }
@@ -13664,6 +13789,7 @@ int main (int argc, char **argv)
           case 12900: size_tmps = kernel_power_max * sizeof (pbkdf2_sha256_tmp_t);   break;
           case 13000: size_tmps = kernel_power_max * sizeof (pbkdf2_sha256_tmp_t);   break;
           case 13200: size_tmps = kernel_power_max * sizeof (axcrypt_tmp_t);         break;
+          case 13400: size_tmps = kernel_power_max * sizeof (keepass_tmp_t);         break;
         };
 
         // size_hooks
@@ -13764,7 +13890,7 @@ int main (int argc, char **argv)
 
       // we don't have sm_* on vendors not NV but it doesn't matter
 
-      snprintf (build_opts, sizeof (build_opts) - 1, "-I%s/ -DVENDOR_ID=%u -DCUDA_ARCH=%d -DVECT_SIZE=%u -DDEVICE_TYPE=%u", shared_dir, device_param->vendor_id, (device_param->sm_major * 100) + device_param->sm_minor, device_param->vector_width, (u32) device_param->device_type);
+      snprintf (build_opts, sizeof (build_opts) - 1, "-I\"%s/\" -DVENDOR_ID=%u -DCUDA_ARCH=%d -DVECT_SIZE=%u -DDEVICE_TYPE=%u", shared_dir, device_param->vendor_id, (device_param->sm_major * 100) + device_param->sm_minor, device_param->vector_width, (u32) device_param->device_type);
 
       /**
        * main kernel
@@ -14683,7 +14809,7 @@ int main (int argc, char **argv)
     if (data.quiet == 0) log_info ("");
 
     /**
-     * Inform user which algorithm is checked and at which workload setting
+     * In benchmark-mode, inform user which algorithm is checked
      */
 
     if (benchmark == 1)
@@ -15046,11 +15172,11 @@ int main (int argc, char **argv)
                   return (-1);
                 }
 
-                char line_buf[BUFSIZ] = { 0 };
+                char *line_buf = (char *) mymalloc (HCBUFSIZ);
 
                 while (!feof (mask_fp))
                 {
-                  memset (line_buf, 0, BUFSIZ);
+                  memset (line_buf, 0, HCBUFSIZ);
 
                   int line_len = fgetl (mask_fp, line_buf);
 
@@ -15070,6 +15196,8 @@ int main (int argc, char **argv)
                   maskcnt++;
                 }
 
+                myfree (line_buf);
+
                 fclose (mask_fp);
               }
               else
@@ -15185,13 +15313,13 @@ int main (int argc, char **argv)
             return (-1);
           }
 
-          char line_buf[BUFSIZ] = { 0 };
+          char *line_buf = (char *) mymalloc (HCBUFSIZ);
 
           uint masks_avail = 1;
 
           while (!feof (mask_fp))
           {
-            memset (line_buf, 0, BUFSIZ);
+            memset (line_buf, 0, HCBUFSIZ);
 
             int line_len = fgetl (mask_fp, line_buf);
 
@@ -15211,6 +15339,8 @@ int main (int argc, char **argv)
             maskcnt++;
           }
 
+          myfree (line_buf);
+
           fclose (mask_fp);
 
           mask_from_file = 1;
@@ -15362,13 +15492,13 @@ int main (int argc, char **argv)
             return (-1);
           }
 
-          char line_buf[BUFSIZ] = { 0 };
+          char *line_buf = (char *) mymalloc (HCBUFSIZ);
 
           uint masks_avail = 1;
 
           while (!feof (mask_fp))
           {
-            memset (line_buf, 0, BUFSIZ);
+            memset (line_buf, 0, HCBUFSIZ);
 
             int line_len = fgetl (mask_fp, line_buf);
 
@@ -15388,6 +15518,8 @@ int main (int argc, char **argv)
             maskcnt++;
           }
 
+          myfree (line_buf);
+
           fclose (mask_fp);
 
           mask_from_file = 1;
@@ -15905,8 +16037,7 @@ int main (int argc, char **argv)
           device_param->speed_pos = 0;
 
           memset (device_param->speed_cnt, 0, SPEED_CACHE * sizeof (u64));
-          memset (device_param->speed_ms,  0, SPEED_CACHE * sizeof (float));
-          memset (device_param->speed_rec, 0, SPEED_CACHE * sizeof (hc_timer_t));
+          memset (device_param->speed_ms,  0, SPEED_CACHE * sizeof (double));
 
           device_param->exec_pos = 0;