Prevent stack buffer overflow in rw_t3t_message_set_block_list

Bug: 142280329
Test: build pass
Change-Id: Ib893ae490056824f9cde4be875475b1614c3eeb3
(cherry picked from commit ea7ce882ed1d8bc3755d3547d3fa61e922d01a56)
diff --git a/src/nfc/tags/rw_t3t.cc b/src/nfc/tags/rw_t3t.cc
index 6ac933d..dce6ba8 100644
--- a/src/nfc/tags/rw_t3t.cc
+++ b/src/nfc/tags/rw_t3t.cc
@@ -1018,6 +1018,14 @@
 
       /* Add service code to T3T message */
       UINT16_TO_STREAM((*p), cur_service_code);
+
+      /* Validate num_services */
+      if (num_services >= T3T_MSG_SERVICE_LIST_MAX) {
+        LOG(ERROR) << StringPrintf(
+            "RW T3T: num_services (%i) reaches maximum (%i)", num_services,
+            T3T_MSG_SERVICE_LIST_MAX);
+        break;
+      }
     }
   }