From dc79983bc94fd90dc78be012790e57e57b51595e Mon Sep 17 00:00:00 2001 From: Jens Steube Date: Sun, 18 Apr 2021 15:19:14 +0200 Subject: [PATCH] Fix out-of-boundary reads in -m 24800 pure kernels --- OpenCL/m24800_a0-pure.cl | 8 ++++---- OpenCL/m24800_a1-pure.cl | 8 ++++---- OpenCL/m24800_a3-pure.cl | 10 ++++++---- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/OpenCL/m24800_a0-pure.cl b/OpenCL/m24800_a0-pure.cl index 4140ed966..54ae82f8c 100644 --- a/OpenCL/m24800_a0-pure.cl +++ b/OpenCL/m24800_a0-pure.cl @@ -52,9 +52,9 @@ KERNEL_FQ void m24800_mxx (KERN_ATTR_RULES ()) u32 t[128] = { 0 }; // make it unicode. - for (u32 i = 0, idx = 0; idx < tmp.pw_len; i += 2, idx += 1) + for (u32 i = 0, idx = 0; i < tmp.pw_len; i += 4, idx += 1) { - make_utf16beN (&tmp.i[idx], &t[i], &t[i+1]); + make_utf16beN (&tmp.i[idx], &t[(idx * 2) + 0], &t[(idx * 2) + 1]); } // hash time @@ -123,9 +123,9 @@ KERNEL_FQ void m24800_sxx (KERN_ATTR_RULES ()) u32 t[128] = { 0 }; // make it unicode. - for (u32 i = 0, idx = 0; idx < tmp.pw_len; i += 2, idx += 1) + for (u32 i = 0, idx = 0; i < tmp.pw_len; i += 4, idx += 1) { - make_utf16beN (&tmp.i[idx], &t[i], &t[i+1]); + make_utf16beN (&tmp.i[idx], &t[(idx * 2) + 0], &t[(idx * 2) + 1]); } // hash time diff --git a/OpenCL/m24800_a1-pure.cl b/OpenCL/m24800_a1-pure.cl index df4733feb..7782975f1 100644 --- a/OpenCL/m24800_a1-pure.cl +++ b/OpenCL/m24800_a1-pure.cl @@ -69,9 +69,9 @@ KERNEL_FQ void m24800_mxx (KERN_ATTR_BASIC ()) u32 t[128] = { 0 }; // make it unicode. - for (u32 i = 0, idx = 0; idx < pw_len + comb_len; i += 2, idx += 1) + for (u32 i = 0, idx = 0; i < pw_len + comb_len; i += 4, idx += 1) { - make_utf16beN (&c[idx], &t[i], &t[i+1]); + make_utf16beN (&c[idx], &t[(idx * 2) + 0], &t[(idx * 2) + 1]); } sha1_hmac_ctx_t ctx; @@ -158,9 +158,9 @@ KERNEL_FQ void m24800_sxx (KERN_ATTR_BASIC ()) u32 t[128] = { 0 }; // make it unicode. - for (u32 i = 0, idx = 0; idx < pw_len + comb_len; i += 2, idx += 1) + for (u32 i = 0, idx = 0; i < pw_len + comb_len; i += 4, idx += 1) { - make_utf16beN (&c[idx], &t[i], &t[i+1]); + make_utf16beN (&c[idx], &t[(idx * 2) + 0], &t[(idx * 2) + 1]); } sha1_hmac_ctx_t ctx; diff --git a/OpenCL/m24800_a3-pure.cl b/OpenCL/m24800_a3-pure.cl index 825b256ca..51d78beb9 100644 --- a/OpenCL/m24800_a3-pure.cl +++ b/OpenCL/m24800_a3-pure.cl @@ -54,9 +54,10 @@ KERNEL_FQ void m24800_mxx (KERN_ATTR_VECTOR ()) u32x t[128] = { 0 }; - for (u32 i = 0, idx = 0; idx < pw_len; i += 2, idx += 1) + // make it unicode. + for (u32 i = 0, idx = 0; i < pw_len; i += 4, idx += 1) { - make_utf16beN (&w[idx], &t[i + 0], &t[i + 1]); + make_utf16beN (&w[idx], &t[(idx * 2) + 0], &t[(idx * 2) + 1]); } sha1_hmac_ctx_vector_t ctx; @@ -128,9 +129,10 @@ KERNEL_FQ void m24800_sxx (KERN_ATTR_VECTOR ()) u32x t[128] = { 0 }; - for (u32 i = 0, idx = 0; idx < pw_len; i += 2, idx += 1) + // make it unicode. + for (u32 i = 0, idx = 0; i < pw_len; i += 4, idx += 1) { - make_utf16beN (&w[idx], &t[i + 0], &t[i + 1]); + make_utf16beN (&w[idx], &t[(idx * 2) + 0], &t[(idx * 2) + 1]); } sha1_hmac_ctx_vector_t ctx;