summaryrefslogtreecommitdiff
path: root/reader.c
diff options
context:
space:
mode:
Diffstat (limited to 'reader.c')
-rw-r--r--reader.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/reader.c b/reader.c
index 2c3a06b..32b17f0 100644
--- a/reader.c
+++ b/reader.c
@@ -4,6 +4,7 @@
#include <sys/timerfd.h>
#include <unistd.h>
#include <string.h>
+#include <ctype.h>
#include "nfcommander.h"
#include "reader.h"
@@ -38,6 +39,21 @@ static struct {
nfc_tag_info_t info;
} tags[MAX_TAGS] = { 0 };
+static void tag_data_sanitize(nfc_tag_info_t* tag){
+ size_t n = 0;
+ for(n = 0; n < tag->static_length; n++){
+ if(tag->static_data[n] && !isprint(tag->static_data[n])){
+ tag->static_data[n] = ' ';
+ }
+ }
+
+ for(n = 0; n < tag->dynamic_length; n++){
+ if(tag->dynamic_data[n] && !isprint(tag->dynamic_data[n])){
+ tag->dynamic_data[n] = ' ';
+ }
+ }
+}
+
static int reader_init_backend(){
char plugin[MAX_PLUGIN_PATH] = "";
char* reader = config_get("nfc", "reader");
@@ -201,6 +217,7 @@ int reader_tag_present(uint8_t flags, nfc_tag_info_t* tag){
if(flags & TAG_STATUS_FLAGS){
memcpy(&(tags[n].info), tag, sizeof(nfc_tag_info_t));
tags[n].flags |= flags;
+ tag_data_sanitize(&(tags[n].info));
return 0;
}
//if data has not yet been fully read, request a full read
@@ -209,7 +226,9 @@ int reader_tag_present(uint8_t flags, nfc_tag_info_t* tag){
if(tags[n].flags & (FLAG_WRITE_FULL | FLAG_WRITE_DYNAMIC)){
flags = tags[n].flags;
+ printf("Requesting %s data write on tag %lu\n", (flags & FLAG_WRITE_FULL) ? "full" : "partial", n);
tags[n].flags &= ~(FLAG_WRITE_FULL | FLAG_WRITE_DYNAMIC);
+ tag_data_sanitize(&(tags[n].info));
//this is kinda dangerous as we hand the reader backend our pointers
memcpy(tag, &(tags[n].info), sizeof(nfc_tag_info_t));