tincctl: Use replace_name to properly replace and validate input hostnames
authorWilliam A. Kennington III <william@wkennington.com>
Mon, 25 Aug 2014 05:35:25 +0000 (22:35 -0700)
committerGuus Sliepen <guus@tinc-vpn.org>
Mon, 25 Aug 2014 07:19:56 +0000 (09:19 +0200)
src/logger.h
src/sptps_keypair.c
src/tincctl.c
src/utils.c

index 637eef8..8f69029 100644 (file)
@@ -65,6 +65,8 @@ enum {
 #endif
 #endif
 
+#include <stdbool.h>
+
 extern debug_t debug_level;
 extern bool logcontrol;
 extern void openlogger(const char *, logmode_t);
index f66a771..399404e 100644 (file)
 
 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"
index 158dfed..f18dc50 100644 (file)
@@ -1305,7 +1305,7 @@ char *get_my_name(bool verbose) {
                        continue;
                if(*value) {
                        fclose(f);
-                       return strdup(value);
+                       return replace_name(value);
                }
        }
 
index db7a8cd..8fbc710 100644 (file)
     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+/";