From 38d7e730e619a8b86dfbf68d77773564595f12a1 Mon Sep 17 00:00:00 2001 From: "William A. Kennington III" Date: Sun, 24 Aug 2014 22:35:25 -0700 Subject: [PATCH] tincctl: Use replace_name to properly replace and validate input hostnames --- src/logger.h | 2 ++ src/sptps_keypair.c | 8 ++++++++ src/tincctl.c | 2 +- src/utils.c | 5 ++--- 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/logger.h b/src/logger.h index 637eef84..8f690290 100644 --- a/src/logger.h +++ b/src/logger.h @@ -65,6 +65,8 @@ enum { #endif #endif +#include + extern debug_t debug_level; extern bool logcontrol; extern void openlogger(const char *, logmode_t); diff --git a/src/sptps_keypair.c b/src/sptps_keypair.c index f66a7711..399404e1 100644 --- a/src/sptps_keypair.c +++ b/src/sptps_keypair.c @@ -27,6 +27,14 @@ static char *program_name; +void logger(int level, int priority, const char *format, ...) { + va_list ap; + va_start(ap, format); + vfprintf(stderr, format, ap); + va_end(ap); + fputc('\n', stderr); +} + static void usage() { fprintf(stderr, "Usage: %s [options] private_key_file public_key_file\n\n", program_name); fprintf(stderr, "Valid options are:\n" diff --git a/src/tincctl.c b/src/tincctl.c index 158dfed8..f18dc50e 100644 --- a/src/tincctl.c +++ b/src/tincctl.c @@ -1305,7 +1305,7 @@ char *get_my_name(bool verbose) { continue; if(*value) { fclose(f); - return strdup(value); + return replace_name(value); } } diff --git a/src/utils.c b/src/utils.c index db7a8cd6..8fbc7108 100644 --- a/src/utils.c +++ b/src/utils.c @@ -18,11 +18,10 @@ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#include "logger.h" #include "system.h" -#include "xalloc.h" - -#include "../src/logger.h" #include "utils.h" +#include "xalloc.h" static const char hexadecimals[] = "0123456789ABCDEF"; static const char base64_original[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; -- 2.20.1