@@ -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