From 01ecc12f13283b4bef9202dc2723ac67aff360bf Mon Sep 17 00:00:00 2001 From: andrethomas Date: Thu, 17 Jan 2019 01:22:51 +0200 Subject: [PATCH] PN532: Prevent non AlphaNumberic on DATA --- sonoff/xsns_40_pn532_i2c.ino | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/sonoff/xsns_40_pn532_i2c.ino b/sonoff/xsns_40_pn532_i2c.ino index c2fdf65e7..dd5fb4aba 100644 --- a/sonoff/xsns_40_pn532_i2c.ino +++ b/sonoff/xsns_40_pn532_i2c.ino @@ -406,7 +406,13 @@ void PN532_ScanForTag(void) uint8_t keyuniversal[6] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; if (mifareclassic_AuthenticateBlock (uid, uid_len, 1, 1, keyuniversal)) { if (mifareclassic_ReadDataBlock(1, card_data)) { - memcpy(&card_datas,&card_data,sizeof(card_data)); // Cast block 1 to a string + for (uint8_t i = 0;i < sizeof(card_data);i++) { + if ((isalpha(card_data[i])) || ((isdigit(card_data[i])))) { + card_datas[i] = char(card_data[i]); + } else { + card_datas[i] = '\0'; + } + } } if (pn532_i2c_function == 1) { // erase block 1 of card for (uint8_t i = 0;i<16;i++) {