Skip to content
This repository was archived by the owner on Apr 24, 2022. It is now read-only.

Commit ce52c74

Browse files
authored
Merge pull request #2147 from ekuznetsov139/master
Avoiding buffer overflow in SHA3
2 parents 47ae149 + 9cb460b commit ce52c74

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

libethash-cuda/ethash_cuda_miner_kernel.cu

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,13 @@ __global__ void ethash_calculate_dag_item(uint32_t start)
5252
uint32_t const node_index = start + blockIdx.x * blockDim.x + threadIdx.x;
5353
if (((node_index >> 1) & (~1)) >= d_dag_size)
5454
return;
55-
56-
hash128_t dag_node;
55+
union {
56+
hash128_t dag_node;
57+
uint2 dag_node_mem[25];
58+
};
5759
copy(dag_node.uint4s, d_light[node_index % d_light_size].uint4s, 4);
5860
dag_node.words[0] ^= node_index;
59-
SHA3_512(dag_node.uint2s);
61+
SHA3_512(dag_node_mem);
6062

6163
const int thread_id = threadIdx.x & 3;
6264

@@ -78,7 +80,7 @@ __global__ void ethash_calculate_dag_item(uint32_t start)
7880
}
7981
}
8082
}
81-
SHA3_512(dag_node.uint2s);
83+
SHA3_512(dag_node_mem);
8284
hash64_t* dag_nodes = (hash64_t*)d_dag;
8385
copy(dag_nodes[node_index].uint4s, dag_node.uint4s, 4);
8486
}

0 commit comments

Comments
 (0)