From bc28d6ce19defc31341f4a0ff2b447b917e624c8 Mon Sep 17 00:00:00 2001 From: ideal Date: Wed, 4 Sep 2019 23:02:13 +0800 Subject: [PATCH 1/4] the remaining size of buffer should minus prefix_len --- echosrv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/echosrv.c b/echosrv.c index e5838d2..66a9675 100644 --- a/echosrv.c +++ b/echosrv.c @@ -106,7 +106,7 @@ void start_echo(int fd) strcpy(buffer, prefix); while (1) { - ret = read(fd, buffer + prefix_len, sizeof(buffer)); + ret = read(fd, buffer + prefix_len, sizeof(buffer) - prefix_len); if (ret == -1) { fprintf(stderr, "%s", strerror(errno)); return; From 125458df5198240bd4e86de1f1f6a5bf436e66b0 Mon Sep 17 00:00:00 2001 From: Jonas Mueller Date: Tue, 5 Nov 2019 20:06:23 +0100 Subject: [PATCH 2/4] Fix warnings for return-type --- common.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common.c b/common.c index 8426e60..4977a4c 100644 --- a/common.c +++ b/common.c @@ -97,12 +97,12 @@ int make_listen_tfo(int s) /* Don't do it if not supported */ if (!TCP_FASTOPEN) - return; + return 0; /* Don't do it if any protocol does not specify it */ for (i = 0; i < cfg.protocols_len; i++) { if (! cfg.protocols[i].tfo_ok) - return; + return 0; } return setsockopt(s, SOL_SOCKET, TCP_FASTOPEN, (char*)&qlen, sizeof(qlen)); From ef8233a83989ddae2f6c9bf6578b317e172332e0 Mon Sep 17 00:00:00 2001 From: Jonas Mueller Date: Tue, 5 Nov 2019 20:11:44 +0100 Subject: [PATCH 3/4] Fix warnings for format-string-security --- sslh-main.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sslh-main.c b/sslh-main.c index bd3594e..1af0dc6 100644 --- a/sslh-main.c +++ b/sslh-main.c @@ -115,7 +115,7 @@ static void printsettings(void) } -/* To removed in v1.21 */ +/* To be removed in v1.21 */ const char* ssl_err_msg = "Usage of 'ssl' setting is deprecated and will be removed in v1.21. Please use 'tls' instead\n"; void ssl_to_tls(char* setting) { @@ -126,7 +126,7 @@ void ssl_to_tls(char* setting) } -/* Turn 'ssl' command line option to 'tls'. To removed in v1.21 */ +/* Turn 'ssl' command line option to 'tls'. To be removed in v1.21 */ void cmd_ssl_to_tls(int argc, char* argv[]) { int i; @@ -135,7 +135,7 @@ void cmd_ssl_to_tls(int argc, char* argv[]) strcpy(argv[i], "--tls"); /* foreground option not parsed yet, syslog not open, just print on * stderr and hope for the best */ - fprintf(stderr, ssl_err_msg); + fprintf(stderr, "%s", ssl_err_msg); } } } From 87aaa156e0a1ea36102939d1a5d8cd1dd64dde61 Mon Sep 17 00:00:00 2001 From: Jonas Mueller Date: Tue, 5 Nov 2019 20:28:58 +0100 Subject: [PATCH 4/4] Add explicit casts to remove warnings for incompatible-pointer-types-discards-qualifiers --- sslh-main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sslh-main.c b/sslh-main.c index 1af0dc6..0fa0994 100644 --- a/sslh-main.c +++ b/sslh-main.c @@ -224,11 +224,11 @@ static void config_protocols() cfg.protocols[i].data = (void*)new_tls_data(); if (cfg.protocols[i].sni_hostnames_len) tls_data_set_list(cfg.protocols[i].data, 0, - cfg.protocols[i].sni_hostnames, + (const char**) cfg.protocols[i].sni_hostnames, cfg.protocols[i].sni_hostnames_len); if (cfg.protocols[i].alpn_protocols_len) tls_data_set_list(cfg.protocols[i].data, 1, - cfg.protocols[i].alpn_protocols, + (const char**) cfg.protocols[i].alpn_protocols, cfg.protocols[i].alpn_protocols_len); } }