From 72493666672a63a8981c56beea231f9f8ace5707 Mon Sep 17 00:00:00 2001 From: jsteube Date: Sun, 20 Nov 2016 13:39:29 +0100 Subject: [PATCH] Fix some possible division by 0 in hm_SYSFS_get_fan_speed_current() --- src/hwmon.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/hwmon.c b/src/hwmon.c index 24513a0f4..18a5c26cd 100644 --- a/src/hwmon.c +++ b/src/hwmon.c @@ -147,6 +147,13 @@ static int hm_SYSFS_get_fan_speed_current (hashcat_ctx_t *hashcat_ctx, const int fclose (fd_max); + if (pwm1_max == 0) + { + event_log_error (hashcat_ctx, "%s: pwm1_max can not be 0", path_max); + + return -1; + } + float pwm1_percent = ((float) pwm1_cur / (float) pwm1_max) * 100.0f; *val = (int) pwm1_percent;