Browse Source

Bugfix: Sanity check for bits exponent in real_block_target

Target is set to the highest possible in this case, so all shares will show as blocks
Luke Dashjr 13 years ago
parent
commit
a419763c07
1 changed files with 7 additions and 0 deletions
  1. 7 0
      util.c

+ 7 - 0
util.c

@@ -586,6 +586,13 @@ void real_block_target(unsigned char *target, const unsigned char *data)
 {
 	uint8_t targetshift;
 
+	if (unlikely(data[72] < 3 || data[72] > 0x20))
+	{
+		// Invalid (out of bounds) target
+		memset(target, 0xff, 32);
+		return;
+	}
+
 	targetshift = data[72] - 3;
 	memset(target, 0, targetshift);
 	target[targetshift++] = data[75];