diff --git a/Makefile.am b/Makefile.am index 37fde7ed..91ba01bd 100644 --- a/Makefile.am +++ b/Makefile.am @@ -37,8 +37,8 @@ CFLAGS += -g CFLAGS += -Wno-long-long -Wall -W -Wnested-externs -Wformat=2 CFLAGS += -Wmissing-prototypes -Wstrict-prototypes -Wmissing-declarations CFLAGS += -Wwrite-strings -Wshadow -Wpointer-arith -Wsign-compare -CFLAGS += -Wundef -Wbad-function-cast -Winline -Wcast-align -CFLAGS += -Wdeclaration-after-statement -Wno-pointer-sign -Wno-attributes +CFLAGS += -Wundef -Wbad-function-cast -Winline +CFLAGS += -Wno-pointer-sign -Wno-attributes CPPFLAGS += -DDEBUG endif if IS_COVERAGE @@ -48,6 +48,9 @@ endif CPPFLAGS += -iquote. endif +CFLAGS += -Wno-unused-parameter -Wno-unused-variable -Wno-null-pointer-arithmetic +CFLAGS += -Wno-format-nonliteral + # Set flags for Solaris. if IS_SUNOS if IS_GCC diff --git a/compat/b64_ntop.c b/compat/b64_ntop.c index 2b4dc2d4..fd8930f5 100644 --- a/compat/b64_ntop.c +++ b/compat/b64_ntop.c @@ -52,6 +52,8 @@ #include #include +#include "compat.h" + #define Assert(Cond) if (!(Cond)) abort() static const char Base64[] = @@ -122,7 +124,7 @@ static const char Pad64 = '='; */ int -b64_ntop(uint8_t const *src, size_t srclength, char *target, size_t targsize) { +b64_ntop(const char *src, size_t srclength, char *target, size_t targsize) { size_t datalength = 0; uint8_t input[3]; uint8_t output[4]; diff --git a/configure.ac b/configure.ac index 5262d670..2035470f 100644 --- a/configure.ac +++ b/configure.ac @@ -2,6 +2,7 @@ AC_INIT(tmate-ssh-server, 2.3.0) +AM_SILENT_RULES([yes]) AC_CONFIG_AUX_DIR(etc) AM_INIT_AUTOMAKE([foreign subdir-objects]) diff --git a/log.c b/log.c index 54d88cbb..2299b6db 100644 --- a/log.c +++ b/log.c @@ -81,6 +81,7 @@ void init_logging(const char *program_name, bool use_syslog, int log_level) } /* Write a log message. */ +__attribute__((__format__(__printf__, 2, 0))) static void log_vwrite(int level, const char *msg, va_list ap) { @@ -121,6 +122,7 @@ log_debug(const char *msg, ...) } /* Log a critical error with error string and die. */ +__attribute__((__format__(__printf__, 1, 0))) __dead void fatal(const char *msg, ...) { @@ -130,11 +132,13 @@ fatal(const char *msg, ...) va_start(ap, msg); if (asprintf(&fmt, "fatal: %s: %s", msg, strerror(errno)) == -1) exit(1); - log_vwrite(LOG_CRIT, fmt, ap); + msg = fmt; + log_vwrite(LOG_CRIT, msg, ap); exit(1); } /* Log a critical error and die. */ +__attribute__((__format__(__printf__, 1, 0))) __dead void fatalx(const char *msg, ...) { @@ -144,10 +148,12 @@ fatalx(const char *msg, ...) va_start(ap, msg); if (asprintf(&fmt, "fatal: %s", msg) == -1) exit(1); - log_vwrite(LOG_CRIT, fmt, ap); + msg = fmt; + log_vwrite(LOG_CRIT, msg, ap); exit(1); } +__attribute__((__format__(__printf__, 2, 0))) void tmate_log(int level, const char *msg, ...) { char *fmt; @@ -160,7 +166,8 @@ void tmate_log(int level, const char *msg, ...) if (asprintf(&fmt, "(tmate) %s", msg) < 0) exit(1); - log_vwrite(level, fmt, ap); + msg = fmt; + log_vwrite(level, msg, ap); va_end(ap); free(fmt); diff --git a/osdep-darwin.c b/osdep-darwin.c index 40b18951..53b48138 100644 --- a/osdep-darwin.c +++ b/osdep-darwin.c @@ -28,7 +28,9 @@ char *osdep_get_name(int, char *); char *osdep_get_cwd(int); struct event_base *osdep_event_init(void); +#ifndef __unused #define __unused __attribute__ ((__unused__)) +#endif char * osdep_get_name(int fd, __unused char *tty) diff --git a/proc.c b/proc.c index fe489181..a8e754b5 100644 --- a/proc.c +++ b/proc.c @@ -100,6 +100,7 @@ proc_event_cb(__unused int fd, short events, void *arg) proc_update_event(peer); } +#ifndef TMATE static void proc_signal_cb(int signo, __unused short events, void *arg) { @@ -107,6 +108,7 @@ proc_signal_cb(int signo, __unused short events, void *arg) tp->signalcb(signo); } +#endif static int peer_check_version(struct tmuxpeer *peer, struct imsg *imsg) diff --git a/session.c b/session.c index a3d1734d..c59a3def 100644 --- a/session.c +++ b/session.c @@ -564,6 +564,7 @@ session_group_index(struct session_group *sg) } fatalx("session group not found"); + for(;;); } /* diff --git a/tmate-ssh-daemon.c b/tmate-ssh-daemon.c index 77ecd1fe..8f224a28 100644 --- a/tmate-ssh-daemon.c +++ b/tmate-ssh-daemon.c @@ -1,5 +1,6 @@ #include "tmate.h" #include +#include struct tmate_session _tmate_session, *tmate_session = &_tmate_session; diff --git a/tmate-ssh-server.c b/tmate-ssh-server.c index 6624ba70..6bcc871c 100644 --- a/tmate-ssh-server.c +++ b/tmate-ssh-server.c @@ -339,10 +339,8 @@ static int get_client_ip_proxy_protocol(int fd, char *dst, size_t len) tok_num = 0; for (char *tok = strtok(header, " "); tok; tok = strtok(NULL, " "), tok_num++) { - if (tok_num == 1) { - strncpy(dst, tok, len); - dst[len-1] = '\0'; - } + if (tok_num == 1) + strlcpy(dst, tok, len); } if (tok_num != 5) diff --git a/xmalloc.c b/xmalloc.c index afa8e585..90af1e2f 100644 --- a/xmalloc.c +++ b/xmalloc.c @@ -94,6 +94,7 @@ xasprintf(char **ret, const char *fmt, ...) return i; } +__attribute__((__format__(__printf__, 2, 0))) int xvasprintf(char **ret, const char *fmt, va_list ap) { @@ -120,6 +121,7 @@ xsnprintf(char *str, size_t len, const char *fmt, ...) return i; } +__attribute__((__format__(__printf__, 3, 0))) int xvsnprintf(char *str, size_t len, const char *fmt, va_list ap) {