Skip to content

Commit

Permalink
Another round of uncrustify code cleanup.
Browse files Browse the repository at this point in the history
After the last big formatting patch a number of changes have been
commited that do not conform with our style/uncrustify config. This
has lead to the problem that running uncrustify on before sending
PR some of the changes made by uncrustify need to be backed out again.

To bring everything back to the agreed upon style, run uncrustify once
more. Uncrustify version used:

	Uncrustify-0.70.1_f

I double checked the result by running uncrustify (Uncrustify-0.69.0_f)
from Ubuntu focal/20.04 which does not do any further changes and
uncrustify 0.66.1_f from Ubuntu bionic/18.04

Signed-off-by: Arne Schwabe <[email protected]>
Acked-by: Gert Doering <[email protected]>
Message-Id: <[email protected]>
URL: https://www.mail-archive.com/[email protected]/msg19750.html
Signed-off-by: Gert Doering <[email protected]>
  • Loading branch information
schwabe authored and cron2 committed Apr 19, 2020
1 parent cbde07f commit 9cf7b49
Show file tree
Hide file tree
Showing 26 changed files with 98 additions and 74 deletions.
2 changes: 1 addition & 1 deletion src/compat/compat-strsep.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,4 @@ strsep(char **stringp, const char *delim)
}
return begin;
}
#endif
#endif /* ifndef HAVE_STRSEP */
3 changes: 2 additions & 1 deletion src/compat/compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ int inet_pton(int af, const char *src, void *dst);
#endif

#ifndef HAVE_STRSEP
char* strsep(char **stringp, const char *delim);
char *strsep(char **stringp, const char *delim);

#endif

#endif /* COMPAT_H */
9 changes: 5 additions & 4 deletions src/openvpn/crypto.c
Original file line number Diff line number Diff line change
Expand Up @@ -736,13 +736,14 @@ crypto_max_overhead(void)
+max_int(OPENVPN_MAX_HMAC_SIZE, OPENVPN_AEAD_TAG_LENGTH);
}

static void warn_insecure_key_type(const char* ciphername, const cipher_kt_t *cipher)
static void
warn_insecure_key_type(const char *ciphername, const cipher_kt_t *cipher)
{
if (cipher_kt_insecure(cipher))
{
msg(M_WARN, "WARNING: INSECURE cipher (%s) with block size less than 128"
" bit (%d bit). This allows attacks like SWEET32. Mitigate by "
"using a --cipher with a larger block size (e.g. AES-256-CBC).",
" bit (%d bit). This allows attacks like SWEET32. Mitigate by "
"using a --cipher with a larger block size (e.g. AES-256-CBC).",
ciphername, cipher_kt_block_size(cipher)*8);
}
}
Expand Down Expand Up @@ -846,7 +847,7 @@ init_key_ctx(struct key_ctx *ctx, const struct key *key,
cipher_ctx_init(ctx->cipher, key->cipher, kt->cipher_length,
kt->cipher, enc);

const char* ciphername = translate_cipher_name_to_openvpn(cipher_kt_name(kt->cipher));
const char *ciphername = translate_cipher_name_to_openvpn(cipher_kt_name(kt->cipher));
msg(D_HANDSHAKE, "%s: Cipher '%s' initialized with %d bit key",
prefix,
ciphername,
Expand Down
5 changes: 3 additions & 2 deletions src/openvpn/cryptoapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -803,12 +803,13 @@ find_certificate_in_store(const char *cert_prop, HCERTSTORE cert_store)
}
blob.cbData = i;
}
else {
else
{
msg(M_WARN, "WARNING: cryptoapicert: unsupported certificate specification <%s>", cert_prop);
goto out;
}

while(true)
while (true)
{
int validity = 1;
/* this frees previous rv, if not NULL */
Expand Down
2 changes: 1 addition & 1 deletion src/openvpn/forward.c
Original file line number Diff line number Diff line change
Expand Up @@ -1278,7 +1278,7 @@ read_incoming_tun(struct context *c)
ASSERT(buf_init(&c->c2.buf, FRAME_HEADROOM(&c->c2.frame)));
ASSERT(buf_safe(&c->c2.buf, MAX_RW_SIZE_TUN(&c->c2.frame)));
c->c2.buf.len = read_tun(c->c1.tuntap, BPTR(&c->c2.buf), MAX_RW_SIZE_TUN(&c->c2.frame));
#endif
#endif /* ifdef _WIN32 */

#ifdef PACKET_TRUNCATION_CHECK
ipv4_packet_size_verify(BPTR(&c->c2.buf),
Expand Down
2 changes: 1 addition & 1 deletion src/openvpn/forward.h
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ io_wait(struct context *c, const unsigned int flags)
c->c2.event_set_status = ret;
}
else
#endif
#endif /* ifdef _WIN32 */
{
/* slow path */
io_wait_dowork(c, flags);
Expand Down
6 changes: 3 additions & 3 deletions src/openvpn/manage.c
Original file line number Diff line number Diff line change
Expand Up @@ -3660,9 +3660,9 @@ management_query_pk_sig(struct management *man, const char *b64_data,
buf_write(&buf_data, ",", (int) strlen(","));
buf_write(&buf_data, algorithm, (int) strlen(algorithm));
}
char* ret = management_query_multiline_flatten(man,
(char *)buf_bptr(&buf_data), prompt, desc,
&man->connection.ext_key_state, &man->connection.ext_key_input);
char *ret = management_query_multiline_flatten(man,
(char *)buf_bptr(&buf_data), prompt, desc,
&man->connection.ext_key_state, &man->connection.ext_key_input);
free_buf(&buf_data);
return ret;
}
Expand Down
2 changes: 1 addition & 1 deletion src/openvpn/misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ auth_user_pass_mgmt(struct user_pass *up, const char *prefix, const unsigned int
}
return true;
}
#endif
#endif /* ifdef ENABLE_MANAGEMENT */

/*
* Get and store a username/password
Expand Down
2 changes: 1 addition & 1 deletion src/openvpn/mroute.c
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ mroute_extract_addr_ether(struct mroute_addr *src,
break;
}
}
#endif
#endif /* ifdef ENABLE_PF */
}
return ret;
}
Expand Down
6 changes: 3 additions & 3 deletions src/openvpn/networking.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ struct context;
#include "networking_iproute2.h"
#else
/* define mock types to ensure code builds on any platform */
typedef void * openvpn_net_ctx_t;
typedef void * openvpn_net_iface_t;
typedef void *openvpn_net_ctx_t;
typedef void *openvpn_net_iface_t;

static inline int
net_ctx_init(struct context *c, openvpn_net_ctx_t *ctx)
Expand All @@ -51,7 +51,7 @@ net_ctx_free(openvpn_net_ctx_t *ctx)
{
(void)ctx;
}
#endif
#endif /* ifdef ENABLE_SITNL */

#if defined(ENABLE_SITNL) || defined(ENABLE_IPROUTE)

Expand Down
14 changes: 14 additions & 0 deletions src/openvpn/networking_iproute2.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ net_ctx_init(struct context *c, openvpn_net_ctx_t *ctx)
{
ctx->es = NULL;
if (c)
{
ctx->es = c->es;
}
ctx->gc = gc_new();

return 0;
Expand Down Expand Up @@ -207,10 +209,14 @@ net_route_v4_add(openvpn_net_ctx_t *ctx, const in_addr_t *dst, int prefixlen,
argv_printf(&argv, "%s route add %s/%d", iproute_path, dst_str, prefixlen);

if (metric > 0)
{
argv_printf_cat(&argv, "metric %d", metric);
}

if (iface)
{
argv_printf_cat(&argv, "dev %s", iface);
}

if (gw)
{
Expand Down Expand Up @@ -246,7 +252,9 @@ net_route_v6_add(openvpn_net_ctx_t *ctx, const struct in6_addr *dst,
}

if (metric > 0)
{
argv_printf_cat(&argv, "metric %d", metric);
}

argv_msg(D_ROUTE, &argv);
openvpn_execve_check(&argv, ctx->es, 0, "ERROR: Linux route -6 add command failed");
Expand All @@ -267,7 +275,9 @@ net_route_v4_del(openvpn_net_ctx_t *ctx, const in_addr_t *dst, int prefixlen,
argv_printf(&argv, "%s route del %s/%d", iproute_path, dst_str, prefixlen);

if (metric > 0)
{
argv_printf_cat(&argv, "metric %d", metric);
}

argv_msg(D_ROUTE, &argv);
openvpn_execve_check(&argv, ctx->es, 0, "ERROR: Linux route delete command failed");
Expand Down Expand Up @@ -296,7 +306,9 @@ net_route_v6_del(openvpn_net_ctx_t *ctx, const struct in6_addr *dst,
}

if (metric > 0)
{
argv_printf_cat(&argv, "metric %d", metric);
}

argv_msg(D_ROUTE, &argv);
openvpn_execve_check(&argv, ctx->es, 0, "ERROR: Linux route -6 del command failed");
Expand All @@ -314,7 +326,9 @@ net_route_v4_best_gw(openvpn_net_ctx_t *ctx, const in_addr_t *dst,

FILE *fp = fopen("/proc/net/route", "r");
if (!fp)
{
return -1;
}

char line[256];
int count = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/openvpn/networking_sitnl.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@
#define NETWORKING_SITNL_H_

typedef char openvpn_net_iface_t;
typedef void * openvpn_net_ctx_t;
typedef void *openvpn_net_ctx_t;

#endif /* NETWORKING_SITNL_H_ */
2 changes: 1 addition & 1 deletion src/openvpn/openvpn.h
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ struct context

struct env_set *es; /**< Set of environment variables. */

openvpn_net_ctx_t net_ctx; /**< Networking API opaque context */
openvpn_net_ctx_t net_ctx; /**< Networking API opaque context */

struct signal_info *sig; /**< Internal error signaling object. */

Expand Down
10 changes: 6 additions & 4 deletions src/openvpn/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -1241,8 +1241,10 @@ print_vlan_accept(enum vlan_acceptable_frames mode)
{
case VLAN_ONLY_TAGGED:
return "tagged";

case VLAN_ONLY_UNTAGGED_OR_PRIORITY:
return "untagged";

case VLAN_ALL:
return "all";
}
Expand Down Expand Up @@ -1320,7 +1322,7 @@ show_p2mp_parms(const struct options *o)
SHOW_STR(port_share_port);
#endif
SHOW_BOOL(vlan_tagging);
msg(D_SHOW_PARMS, " vlan_accept = %s", print_vlan_accept (o->vlan_accept));
msg(D_SHOW_PARMS, " vlan_accept = %s", print_vlan_accept(o->vlan_accept));
SHOW_INT(vlan_pvid);
#endif /* P2MP_SERVER */

Expand Down Expand Up @@ -5301,7 +5303,7 @@ add_option(struct options *options,
options->management_flags |= MF_EXTERNAL_CERT;
options->management_certificate = p[1];
}
#endif
#endif /* ifdef ENABLE_MANAGEMENT */
#ifdef MANAGEMENT_DEF_AUTH
else if (streq(p[0], "management-client-auth") && !p[1])
{
Expand Down Expand Up @@ -7711,8 +7713,8 @@ add_option(struct options *options,
}
else
{
if (streq(p[1], "secret") || streq(p[1], "tls-auth") ||
streq(p[1], "tls-crypt"))
if (streq(p[1], "secret") || streq(p[1], "tls-auth")
|| streq(p[1], "tls-crypt"))
{
options->genkey_type = GENKEY_SECRET;
}
Expand Down
4 changes: 2 additions & 2 deletions src/openvpn/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,8 @@ struct options
bool show_curves;
bool genkey;
enum genkey_type genkey_type;
const char* genkey_filename;
const char* genkey_extra_data;
const char *genkey_filename;
const char *genkey_extra_data;

/* Networking parms */
int connect_retry_max;
Expand Down
2 changes: 1 addition & 1 deletion src/openvpn/proto.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ struct openvpn_ethhdr
struct openvpn_8021qhdr
{
uint8_t dest[OPENVPN_ETH_ALEN]; /* destination ethernet addr */
uint8_t source[OPENVPN_ETH_ALEN]; /* source ethernet addr */
uint8_t source[OPENVPN_ETH_ALEN]; /* source ethernet addr */

uint16_t tpid; /* 802.1Q Tag Protocol Identifier */
#define OPENVPN_8021Q_MASK_PCP htons(0xE000) /* mask PCP out of pcp_cfi_vid */
Expand Down
20 changes: 10 additions & 10 deletions src/openvpn/push.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,19 +72,19 @@ receive_auth_failed(struct context *c, const struct buffer *buffer)
{
switch (auth_retry_get())
{
case AR_NONE:
c->sig->signal_received = SIGTERM; /* SOFT-SIGTERM -- Auth failure error */
break;
case AR_NONE:
c->sig->signal_received = SIGTERM; /* SOFT-SIGTERM -- Auth failure error */
break;

case AR_INTERACT:
ssl_purge_auth(false);
case AR_INTERACT:
ssl_purge_auth(false);

case AR_NOINTERACT:
c->sig->signal_received = SIGUSR1; /* SOFT-SIGUSR1 -- Auth failure error */
break;
case AR_NOINTERACT:
c->sig->signal_received = SIGUSR1; /* SOFT-SIGUSR1 -- Auth failure error */
break;

default:
ASSERT(0);
default:
ASSERT(0);
}
c->sig->signal_text = "auth-failure";
}
Expand Down
2 changes: 1 addition & 1 deletion src/openvpn/route.c
Original file line number Diff line number Diff line change
Expand Up @@ -2152,7 +2152,7 @@ delete_route(struct route_ipv4 *r,
#if !defined(TARGET_ANDROID)
const char *gateway;
#endif
#else
#else /* if !defined(TARGET_LINUX) */
int metric;
#endif
int is_local_route;
Expand Down
6 changes: 4 additions & 2 deletions src/openvpn/ssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ ssl_set_auth_token(const char *token)
* Cleans an auth token and checks if it was active
*/
bool
ssl_clean_auth_token (void)
ssl_clean_auth_token(void)
{
bool wasdefined = auth_token.defined;
purge_user_pass(&auth_token, true);
Expand Down Expand Up @@ -2015,7 +2015,7 @@ tls_session_update_crypto_params(struct tls_session *session,
{
frame_remove_from_extra_frame(frame_fragment, crypto_max_overhead());
crypto_adjust_frame_parameters(frame_fragment, &session->opt->key_type,
options->replay, packet_id_long_form);
options->replay, packet_id_long_form);
frame_set_mtu_dynamic(frame_fragment, options->ce.fragment, SET_MTU_UPPER_BOUND);
frame_print(frame_fragment, D_MTU_INFO, "Fragmentation MTU parms");
}
Expand Down Expand Up @@ -2411,7 +2411,9 @@ key_method_2_write(struct buffer *buf, struct tls_session *session)
* username/password
*/
if (auth_token.defined)
{
up = &auth_token;
}

if (!write_string(buf, up->username, -1))
{
Expand Down
1 change: 1 addition & 0 deletions src/openvpn/ssl.h
Original file line number Diff line number Diff line change
Expand Up @@ -607,4 +607,5 @@ void
show_available_tls_ciphers(const char *cipher_list,
const char *cipher_list_tls13,
const char *tls_cert_profile);

#endif /* ifndef OPENVPN_SSL_H */
15 changes: 8 additions & 7 deletions src/openvpn/ssl_mbedtls.c
Original file line number Diff line number Diff line change
Expand Up @@ -191,12 +191,13 @@ tls_ctx_initialised(struct tls_root_ctx *ctx)
}

#ifdef HAVE_EXPORT_KEYING_MATERIAL
int mbedtls_ssl_export_keys_cb(void *p_expkey, const unsigned char *ms,
const unsigned char *kb, size_t maclen,
size_t keylen, size_t ivlen,
const unsigned char client_random[32],
const unsigned char server_random[32],
mbedtls_tls_prf_types tls_prf_type)
int
mbedtls_ssl_export_keys_cb(void *p_expkey, const unsigned char *ms,
const unsigned char *kb, size_t maclen,
size_t keylen, size_t ivlen,
const unsigned char client_random[32],
const unsigned char server_random[32],
mbedtls_tls_prf_types tls_prf_type)
{
struct tls_session *session = p_expkey;
struct key_state_ssl *ks_ssl = &session->key[KS_PRIMARY].ks_ssl;
Expand Down Expand Up @@ -1115,7 +1116,7 @@ key_state_ssl_init(struct key_state_ssl *ks_ssl,
if (session->opt->ekm_size)
{
mbedtls_ssl_conf_export_keys_ext_cb(ks_ssl->ssl_config,
mbedtls_ssl_export_keys_cb, session);
mbedtls_ssl_export_keys_cb, session);
}
#endif

Expand Down
Loading

0 comments on commit 9cf7b49

Please sign in to comment.