Diff between 1b695735719690c78a5e42ba3b8b449a13cb7245 and 9e08218d0f52f573f9c1d12df650647d4a833d0c

Changed Files

File Additions Deletions Status
tools/smp-tester.c +8 -3 modified

Full Patch

diff --git a/tools/smp-tester.c b/tools/smp-tester.c
index aa55402..05d620a 100644
--- a/tools/smp-tester.c
+++ b/tools/smp-tester.c
@@ -661,7 +661,14 @@ static void smp_server(const void *data, uint16_t len, void *user_data)
 	const void *pdu;
 	uint8_t opcode;
 
-	tester_print("Received SMP PDU");
+	if (len < 1) {
+		tester_warn("Received too small SMP PDU");
+		goto failed;
+	}
+
+	opcode = *((const uint8_t *) data);
+
+	tester_print("Received SMP opcode 0x%02x", opcode);
 
 	if (test_data->counter >= smp->req_count) {
 		tester_test_passed();
@@ -678,8 +685,6 @@ static void smp_server(const void *data, uint16_t len, void *user_data)
 		goto failed;
 	}
 
-	opcode = *((const uint8_t *) data);
-
 	switch (opcode) {
 	case 0x01: /* Pairing Request */
 		memcpy(test_data->smp_preq, data, sizeof(test_data->smp_preq));