mirror of
https://gitlab.com/openconnect/ocserv.git
synced 2026-02-09 08:16:58 +08:00
Merge branch 'tests-strlcpy' into 'master'
tests: replace strcpy() with strlcpy() See merge request openconnect/ocserv!493
This commit is contained in:
@@ -34,6 +34,8 @@
|
||||
/* This global variable is used by oc_syslog() */
|
||||
int global_log_prio = DEFAULT_LOG_LEVEL;
|
||||
|
||||
int syslog_open;
|
||||
|
||||
void __attribute__((format(printf, 2, 3))) oc_syslog(int priority,
|
||||
const char *fmt, ...)
|
||||
{
|
||||
|
||||
@@ -82,7 +82,6 @@ char **worker_argv;
|
||||
static void listen_watcher_cb(EV_P_ ev_io *w, int revents);
|
||||
static void resume_accept_cb(EV_P_ ev_timer *w, int revents);
|
||||
|
||||
int syslog_open;
|
||||
sigset_t sig_default_set;
|
||||
struct ev_loop *main_loop;
|
||||
static unsigned int allow_broken_clients;
|
||||
|
||||
@@ -30,8 +30,6 @@
|
||||
#include <locale.h>
|
||||
#include <occtl/occtl.h>
|
||||
|
||||
int syslog_open;
|
||||
|
||||
static int handle_reset_cmd(CONN_TYPE *conn, const char *arg,
|
||||
cmd_params_st *params);
|
||||
static int handle_help_cmd(CONN_TYPE *conn, const char *arg,
|
||||
|
||||
@@ -115,8 +115,6 @@ inline static const char *proto_to_str(fw_proto_t proto)
|
||||
#define REKEY_METHOD_SSL 1
|
||||
#define REKEY_METHOD_NEW_TUNNEL 2
|
||||
|
||||
extern int syslog_open;
|
||||
|
||||
/* the first is generic, for the methods that require a username password */
|
||||
#define AUTH_TYPE_USERNAME_PASS (1 << 0)
|
||||
#define AUTH_TYPE_PAM (1 << 1 | AUTH_TYPE_USERNAME_PASS)
|
||||
|
||||
@@ -45,7 +45,6 @@ asn1_node _kkdcp_pkix1_asn;
|
||||
|
||||
extern struct snapshot_t *config_snapshot;
|
||||
|
||||
int syslog_open;
|
||||
sigset_t sig_default_set;
|
||||
static unsigned int allow_broken_clients;
|
||||
|
||||
|
||||
@@ -133,7 +133,7 @@ AM_CPPFLAGS += \
|
||||
-I$(top_srcdir)/ \
|
||||
-I$(top_builddir)/
|
||||
|
||||
LDADD = $(LIBTALLOC_LIBS) ../src/libccan.a $(CODE_COVERAGE_LDFLAGS)
|
||||
LDADD = ../src/libcommon.a $(LIBNETTLE_LIBS) $(LIBTALLOC_LIBS) ../src/libccan.a $(CODE_COVERAGE_LDFLAGS)
|
||||
|
||||
kkdcp_parsing_SOURCES = kkdcp-parsing.c
|
||||
kkdcp_parsing_LDADD = $(LDADD)
|
||||
|
||||
@@ -30,8 +30,6 @@
|
||||
#include "../src/ip-util.h"
|
||||
#include "../src/main-ban.c"
|
||||
|
||||
int syslog_open;
|
||||
|
||||
/* Test the IP banning functionality */
|
||||
static unsigned int check_if_banned_str(main_server_st *s, const char *ip)
|
||||
{
|
||||
|
||||
@@ -36,8 +36,6 @@ static unsigned int verbose;
|
||||
|
||||
#include "../src/tlslib.c"
|
||||
|
||||
int syslog_open;
|
||||
|
||||
int get_cert_names(worker_st *ws, const gnutls_datum_t *raw)
|
||||
{
|
||||
return 0;
|
||||
|
||||
@@ -27,8 +27,6 @@
|
||||
#include "../src/html.c"
|
||||
#include "../src/common/common.h"
|
||||
|
||||
int syslog_open;
|
||||
|
||||
static char *strings[] = {
|
||||
|
||||
"hello there",
|
||||
|
||||
@@ -25,8 +25,6 @@
|
||||
#include "../src/ip-util.h"
|
||||
#include "../src/ip-util.c"
|
||||
|
||||
int syslog_open = 0;
|
||||
|
||||
static unsigned int ip_to_sockaddr(const char *ip, unsigned int port,
|
||||
struct sockaddr_storage *ss)
|
||||
{
|
||||
|
||||
@@ -23,8 +23,6 @@
|
||||
#include "../src/ip-util.h"
|
||||
#include "../src/ip-util.c"
|
||||
|
||||
int syslog_open;
|
||||
|
||||
int main(void)
|
||||
{
|
||||
char *p;
|
||||
|
||||
@@ -23,8 +23,6 @@
|
||||
#include "../src/ip-util.h"
|
||||
#include "../src/ip-util.c"
|
||||
|
||||
int syslog_open;
|
||||
|
||||
static char *my_ipv6_prefix_to_mask(char str[MAX_IP_STR], unsigned int prefix)
|
||||
{
|
||||
struct in6_addr in;
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include <sys/socket.h>
|
||||
#include <netdb.h>
|
||||
|
||||
#include "../src/common/common.h"
|
||||
#include "../src/common-config.h"
|
||||
#include "../src/config-kkdcp.c"
|
||||
|
||||
@@ -36,7 +37,7 @@ int main(void)
|
||||
char *port, *server, *path, *realm;
|
||||
int socktype;
|
||||
|
||||
strcpy(p, "/KdcProxy KERBEROS.REALM udp@127.0.0.1:88");
|
||||
strlcpy(p, "/KdcProxy KERBEROS.REALM udp@127.0.0.1:88", sizeof(p));
|
||||
|
||||
parse_kkdcp_string(p, &socktype, &port, &server, &path, &realm);
|
||||
if (socktype != SOCK_DGRAM || strcmp(port, "88") != 0 ||
|
||||
@@ -48,7 +49,7 @@ int main(void)
|
||||
exit(2);
|
||||
}
|
||||
|
||||
strcpy(p, "/KdcProxy KERBEROS.REALM tcp@[::1]:88");
|
||||
strlcpy(p, "/KdcProxy KERBEROS.REALM tcp@[::1]:88", sizeof(p));
|
||||
|
||||
parse_kkdcp_string(p, &socktype, &port, &server, &path, &realm);
|
||||
if (socktype != SOCK_STREAM || strcmp(port, "88") != 0 ||
|
||||
@@ -60,8 +61,9 @@ int main(void)
|
||||
exit(2);
|
||||
}
|
||||
|
||||
strcpy(p,
|
||||
"/KdcProxy-xxx KERBEROS.REALM udp@[fc74:cc44:8f86:0252:47d4:54bf:112b:970c]:8899");
|
||||
strlcpy(p,
|
||||
"/KdcProxy-xxx KERBEROS.REALM udp@[fc74:cc44:8f86:0252:47d4:54bf:112b:970c]:8899",
|
||||
sizeof(p));
|
||||
|
||||
parse_kkdcp_string(p, &socktype, &port, &server, &path, &realm);
|
||||
if (socktype != SOCK_DGRAM || strcmp(port, "8899") != 0 ||
|
||||
|
||||
@@ -24,12 +24,11 @@
|
||||
#include <sys/socket.h>
|
||||
#include <netdb.h>
|
||||
|
||||
#include "../src/common/common.h"
|
||||
#include "../src/common-config.h"
|
||||
#include "../src/config-ports.c"
|
||||
#include "../src/ipc.pb-c.h"
|
||||
|
||||
int syslog_open;
|
||||
|
||||
#define reset(x, y) \
|
||||
{ \
|
||||
talloc_free(x); \
|
||||
@@ -76,8 +75,9 @@ int main(void)
|
||||
size_t n_fw_ports = 0;
|
||||
void *pool = talloc_new(NULL);
|
||||
|
||||
strcpy(p,
|
||||
"icmp(), tcp(88), udp(90), sctp(70), tcp(443), udp(80), icmpv6()");
|
||||
strlcpy(p,
|
||||
"icmp(), tcp(88), udp(90), sctp(70), tcp(443), udp(80), icmpv6()",
|
||||
sizeof(p));
|
||||
|
||||
ret = cfg_parse_ports(pool, &fw_ports, &n_fw_ports, p);
|
||||
if (ret < 0) {
|
||||
@@ -89,8 +89,9 @@ int main(void)
|
||||
|
||||
/* check spacing tolerance */
|
||||
reset(fw_ports, n_fw_ports);
|
||||
strcpy(p,
|
||||
"icmp ( ), tcp ( 88 ), udp ( 90 ), sctp ( 70 ) , tcp ( 443 ) , udp(80) , icmpv6 ( ) ");
|
||||
strlcpy(p,
|
||||
"icmp ( ), tcp ( 88 ), udp ( 90 ), sctp ( 70 ) , tcp ( 443 ) , udp(80) , icmpv6 ( ) ",
|
||||
sizeof(p));
|
||||
|
||||
ret = cfg_parse_ports(pool, &fw_ports, &n_fw_ports, p);
|
||||
if (ret < 0) {
|
||||
@@ -102,7 +103,7 @@ int main(void)
|
||||
|
||||
/* test error 1 */
|
||||
reset(fw_ports, n_fw_ports);
|
||||
strcpy(p, "tcp(88), tcp(90),");
|
||||
strlcpy(p, "tcp(88), tcp(90),", sizeof(p));
|
||||
ret = cfg_parse_ports(pool, &fw_ports, &n_fw_ports, p);
|
||||
if (ret >= 0) {
|
||||
fprintf(stderr, "error in %d\n", __LINE__);
|
||||
@@ -111,7 +112,7 @@ int main(void)
|
||||
|
||||
/* test error 2 */
|
||||
reset(fw_ports, n_fw_ports);
|
||||
strcpy(p, "tcp(88), tcp");
|
||||
strlcpy(p, "tcp(88), tcp", sizeof(p));
|
||||
ret = cfg_parse_ports(pool, &fw_ports, &n_fw_ports, p);
|
||||
if (ret >= 0) {
|
||||
fprintf(stderr, "error in %d\n", __LINE__);
|
||||
@@ -119,8 +120,9 @@ int main(void)
|
||||
}
|
||||
|
||||
reset(fw_ports, n_fw_ports);
|
||||
strcpy(p,
|
||||
"!(icmp(), tcp(88), udp(90), sctp(70), tcp(443), udp(80), icmpv6())");
|
||||
strlcpy(p,
|
||||
"!(icmp(), tcp(88), udp(90), sctp(70), tcp(443), udp(80), icmpv6())",
|
||||
sizeof(p));
|
||||
|
||||
ret = cfg_parse_ports(pool, &fw_ports, &n_fw_ports, p);
|
||||
if (ret < 0) {
|
||||
|
||||
@@ -29,7 +29,7 @@ int main(void)
|
||||
{
|
||||
char str[64];
|
||||
|
||||
strcpy(str, STR1 " ");
|
||||
strlcpy(str, STR1 " ", sizeof(str));
|
||||
|
||||
trim_trailing_whitespace(str);
|
||||
|
||||
@@ -38,7 +38,7 @@ int main(void)
|
||||
exit(1);
|
||||
}
|
||||
|
||||
strcpy(str, STR1 " ");
|
||||
strlcpy(str, STR1 " ", sizeof(str));
|
||||
|
||||
trim_trailing_whitespace(str);
|
||||
|
||||
@@ -47,7 +47,7 @@ int main(void)
|
||||
exit(1);
|
||||
}
|
||||
|
||||
strcpy(str, STR1);
|
||||
strlcpy(str, STR1, sizeof(str));
|
||||
|
||||
trim_trailing_whitespace(str);
|
||||
|
||||
@@ -56,7 +56,7 @@ int main(void)
|
||||
exit(1);
|
||||
}
|
||||
|
||||
strcpy(str, " " STR1);
|
||||
strlcpy(str, " " STR1, sizeof(str));
|
||||
|
||||
trim_trailing_whitespace(str);
|
||||
|
||||
@@ -65,7 +65,7 @@ int main(void)
|
||||
exit(1);
|
||||
}
|
||||
|
||||
strcpy(str, " ");
|
||||
strlcpy(str, " ", sizeof(str));
|
||||
|
||||
trim_trailing_whitespace(str);
|
||||
|
||||
|
||||
@@ -26,8 +26,6 @@
|
||||
#include "../src/html.h"
|
||||
#include "../src/html.c"
|
||||
|
||||
int syslog_open;
|
||||
|
||||
static char *strings[] = {
|
||||
|
||||
"Laguna+Beach", "_+-.~%2C", "Laguna%25%2B%40Beach"
|
||||
|
||||
Reference in New Issue
Block a user