From 0c4fbb7ed90cf052733b3893a740cb51e3f8f13b Mon Sep 17 00:00:00 2001 From: Tom Thorogood Date: Fri, 2 Apr 2021 23:09:26 +1030 Subject: [PATCH] Print logging and debugging messages to stderr --- fido2/log.c | 6 +++--- fido2/util.c | 4 ++-- pc/device.c | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/fido2/log.c b/fido2/log.c index bb9a41ad..9baade6c 100644 --- a/fido2/log.c +++ b/fido2/log.c @@ -72,7 +72,7 @@ void LOG(uint32_t tag, const char * filename, int num, const char * fmt, ...) { if (tag & tagtable[i].tagn) { - if (tagtable[i].tag[0] && !(tag & TAG_NO_TAG)) printf("[%s] ", tagtable[i].tag); + if (tagtable[i].tag[0] && !(tag & TAG_NO_TAG)) fprintf(stderr, "[%s] ", tagtable[i].tag); i = 0; break; } @@ -86,12 +86,12 @@ void LOG(uint32_t tag, const char * filename, int num, const char * fmt, ...) #ifdef ENABLE_FILE_LOGGING if (tag & TAG_FILENO) { - printf("%s:%d: ", filename, num); + fprintf(stderr, "%s:%d: ", filename, num); } #endif va_list args; va_start(args, fmt); - vprintf(fmt, args); + vfprintf(stderr, fmt, args); va_end(args); } diff --git a/fido2/util.c b/fido2/util.c index 6092f77e..f6a68474 100644 --- a/fido2/util.c +++ b/fido2/util.c @@ -11,7 +11,7 @@ void dump_hex(uint8_t * buf, int size) { while(size--) { - printf("%02x ", *buf++); + fprintf(stderr, "%02x ", *buf++); } - printf("\n"); + fprintf(stderr, "\n"); } diff --git a/pc/device.c b/pc/device.c index 5c9b4aca..deed3db2 100644 --- a/pc/device.c +++ b/pc/device.c @@ -202,7 +202,7 @@ void usbhid_close() void int_handler(int i) { usbhid_close(); - printf("SIGINT... exiting.\n"); + fprintf(stderr, "SIGINT... exiting.\n"); exit(0); } @@ -364,7 +364,7 @@ void authenticator_initialize() uint8_t * mem; if (access(state_file, F_OK) != -1) { - printf("state file exists\n"); + fprintf(stderr, "state file exists\n"); f = fopen(state_file, "rb"); if (f== NULL) { @@ -398,7 +398,7 @@ void authenticator_initialize() } else { - printf("state file does not exist, creating it\n"); + fprintf(stderr, "state file does not exist, creating it\n"); f = fopen(state_file, "wb+"); if (f== NULL) {