Skip to content

Commit d6ccd09

Browse files
committed
feat: additional sanity checks
1 parent bdeab74 commit d6ccd09

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/devices/compustar_700r.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,6 @@ ID: hhhhh BUTTON: bbbbb UNKNOWN: bbb
4646

4747
static int compustar_700r_decode(r_device *decoder, bitbuffer_t *bitbuffer)
4848
{
49-
int id = 0;
50-
int button = 0;
51-
5249
if (bitbuffer->bits_per_row[0] != 25) {
5350
return DECODE_ABORT_LENGTH;
5451
}
@@ -63,8 +60,12 @@ static int compustar_700r_decode(r_device *decoder, bitbuffer_t *bitbuffer)
6360
return DECODE_ABORT_EARLY;
6461
}
6562

66-
id = bytes[0] << 12 | bytes[1] << 4 | bytes[2] >> 4;
67-
button = ~(bytes[2] << 1 | bytes[3] >> 7) & 0x1f;
63+
int id = bytes[0] << 12 | bytes[1] << 4 | bytes[2] >> 4;
64+
int button = ~(bytes[2] << 1 | bytes[3] >> 7) & 0x1f;
65+
66+
if ((bytes[4] & 0x7) != 0x0 || button == 0 || id == 0) {
67+
return DECODE_ABORT_EARLY;
68+
}
6869

6970
// button flags
7071
int unlock = (button & 0x2) >> 1;

0 commit comments

Comments
 (0)