Skip to content

Commit ea460df

Browse files
committed
Fix split string warnings and add event.c to autotools build
Join split JSON format string literals onto single lines to satisfy checkpatch SPLIT_STRING without needing an ignore rule. Add event.c, event.h, and exit_codes.h to Makefile.am for autotools builds.
1 parent fcbaf3d commit ea460df

4 files changed

Lines changed: 28 additions & 26 deletions

File tree

CMakeLists.txt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ find_package(OpenSSL REQUIRED)
1414
# Common sources (platform-independent)
1515
set(COMMON_SOURCES
1616
src/config.c
17+
src/event.c
1718
src/hdlc.c
1819
src/http.c
1920
src/xml.c
@@ -36,10 +37,6 @@ if(WIN32)
3637
if(MSVC)
3738
list(APPEND PLATFORM_SOURCES lib/getopt/getopt.c)
3839
set(GETOPT_INCLUDE_DIR "${CMAKE_SOURCE_DIR}/lib/getopt")
39-
40-
# PThreads4W for MSVC (MinGW has its own pthreads)
41-
find_package(PThreads4W REQUIRED)
42-
list(APPEND PLATFORM_LIBS PThreads4W::PThreads4W)
4340
endif()
4441

4542
# Platform definitions

Makefile.am

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# http://mij.oltrelinux.com/devel/autoconf-automake/
22

33
bin_PROGRAMS = openfortivpn
4-
openfortivpn_SOURCES = src/config.c src/config.h src/hdlc.c src/hdlc.h \
4+
openfortivpn_SOURCES = src/config.c src/config.h src/event.c src/event.h \
5+
src/exit_codes.h src/hdlc.c src/hdlc.h \
56
src/http.c src/http.h src/io.c src/io.h \
67
src/http_server.c src/ipv4.c \
78
src/ipv4.h src/log.c src/log.h src/tunnel.c \

src/io_win.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -324,8 +324,7 @@ static void *tun_read_thread(void *arg)
324324
&tunnel->pty_to_ssl_pool,
325325
packet);
326326
log_debug(
327-
"tun ---> gateway"
328-
" (%lu bytes)\n",
327+
"tun ---> gateway (%lu bytes)\n",
329328
(unsigned long)ppp_len);
330329
}
331330
free(ppp_data);

src/tunnel_win.c

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,7 @@ static int wintun_create(struct tunnel *tunnel)
7878
/* Create the adapter */
7979
adapter = wt_api.CreateAdapter(ADAPTER_NAME, TUNNEL_TYPE, NULL);
8080
if (!adapter) {
81-
log_error("Failed to create wintun adapter (error %lu).\n"
82-
"Ensure you are running as Administrator.\n",
81+
log_error("Failed to create wintun adapter (error %lu).\nEnsure you are running as Administrator.\n",
8382
GetLastError());
8483
return 1;
8584
}
@@ -343,10 +342,14 @@ int ssl_connect(struct tunnel *tunnel)
343342
log_error("Server certificate verification failed.\n");
344343
log_error("Certificate digest: %s\n",
345344
digest_str);
346-
event_emit("cert_error",
347-
"\"digest\":\"%s\","
348-
"\"reason\":\"verification_failed\"",
349-
digest_str);
345+
{
346+
char buf[256];
347+
348+
snprintf(buf, sizeof(buf),
349+
"\"digest\":\"%s\",\"reason\":\"verification_failed\"",
350+
digest_str);
351+
event_emit("cert_error", buf);
352+
}
350353
return OFV_EXIT_CERT_FAILED;
351354
}
352355
log_debug("Trusted certificate matched.\n");
@@ -395,11 +398,14 @@ static int get_gateway_host_ip(struct tunnel *tunnel)
395398
if (ret != 0 || !result) {
396399
log_error("Could not resolve host: %s\n",
397400
tunnel->config->gateway_host);
398-
event_emit("error",
399-
"\"code\":%d,"
400-
"\"category\":\"dns\","
401-
"\"message\":\"Could not resolve host\"",
402-
OFV_EXIT_DNS_FAILED);
401+
{
402+
char buf[128];
403+
404+
snprintf(buf, sizeof(buf),
405+
"\"code\":%d,\"category\":\"dns\",\"message\":\"Could not resolve host\"",
406+
OFV_EXIT_DNS_FAILED);
407+
event_emit("error", buf);
408+
}
403409
return 1;
404410
}
405411

@@ -443,15 +449,16 @@ static int on_ppp_if_up(struct tunnel *tunnel)
443449
char dns1_str[INET_ADDRSTRLEN] = "";
444450
char dns2_str[INET_ADDRSTRLEN] = "";
445451

452+
char buf[256];
453+
446454
inet_ntop(AF_INET, &tunnel->ipv4.ns1_addr,
447455
dns1_str, sizeof(dns1_str));
448456
inet_ntop(AF_INET, &tunnel->ipv4.ns2_addr,
449457
dns2_str, sizeof(dns2_str));
450-
event_emit("tunnel_up",
451-
"\"local_ip\":\"%s\","
452-
"\"dns1\":\"%s\","
453-
"\"dns2\":\"%s\"",
454-
ip_str, dns1_str, dns2_str);
458+
snprintf(buf, sizeof(buf),
459+
"\"local_ip\":\"%s\",\"dns1\":\"%s\",\"dns2\":\"%s\"",
460+
ip_str, dns1_str, dns2_str);
461+
event_emit("tunnel_up", buf);
455462
}
456463
}
457464

@@ -590,9 +597,7 @@ int run_tunnel(struct vpn_config *config)
590597
event_emit("state_change", "\"state\":\"tunneling\"");
591598
log_debug("Switch to tunneling mode\n");
592599
ret = http_send(&tunnel,
593-
"GET /remote/sslvpn-tunnel HTTP/1.1\r\n"
594-
"Host: sslvpn\r\n"
595-
"Cookie: %s\r\n\r\n",
600+
"GET /remote/sslvpn-tunnel HTTP/1.1\r\nHost: sslvpn\r\nCookie: %s\r\n\r\n",
596601
tunnel.cookie);
597602
if (ret != 1) {
598603
log_error("Could not start tunnel.\n");

0 commit comments

Comments
 (0)