aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Greer <mgreer@animalcreek.com>2017-02-16 17:48:50 +0000
committerSamuel Ortiz <sameo@linux.intel.com>2017-11-10 00:16:54 +0100
commit564e38bbaceb3ad19ff07ebddaf11b7001ef8ace (patch)
tree85bea3de2586ab11f6fb6c5d8335bb1b86fdbf2b
parent047b0dff62ba02a619901fc24317a5dc6745dc24 (diff)
downloadneard-564e38bbaceb3ad19ff07ebddaf11b7001ef8ace.tar.gz
ndef: Verify RTD record type name encodings
The NFC Forum's Record Type Definition (RTD) Technical Specification version 1.0, section 3.4 (RTD Type Names Requirements) specifies that RTD type name encodings MUST be done according to the ASCII chart in Appendix A (Character Set for Record Types). Enforce this by checking that all of the RTD type name encodings are valid before determining their type. Conveniently, isprint() does the correct checking. Signed-off-by: Mark Greer <mgreer@animalcreek.com>
-rw-r--r--src/ndef.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/ndef.c b/src/ndef.c
index d172dbc..6918f45 100644
--- a/src/ndef.c
+++ b/src/ndef.c
@@ -27,6 +27,7 @@
#include <stdlib.h>
#include <errno.h>
#include <string.h>
+#include <ctype.h>
#include <glib.h>
@@ -881,6 +882,8 @@ static enum record_type get_external_record_type(uint8_t *type,
static enum record_type get_record_type(enum record_tnf tnf,
uint8_t *type, size_t type_length)
{
+ unsigned int i;
+
DBG("");
switch (tnf) {
@@ -891,6 +894,10 @@ static enum record_type get_record_type(enum record_tnf tnf,
break;
case RECORD_TNF_WELLKNOWN:
+ for (i = 0; i < type_length; i++)
+ if (!isprint(type[i]))
+ return RECORD_TYPE_ERROR;
+
if (type_length == 1) {
if (type[0] == 'T')
return RECORD_TYPE_WKT_TEXT;