Skip to content

Commit

Permalink
Uniform coding style: space and tabs
Browse files Browse the repository at this point in the history
This patch just play with space and tabs, so
	git diff -w
does not report anything.

Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
  • Loading branch information
borneoa authored and David Woodhouse committed Mar 10, 2013
1 parent 4acd008 commit 0450c12
Show file tree
Hide file tree
Showing 15 changed files with 215 additions and 215 deletions.
6 changes: 3 additions & 3 deletions auth.c
Expand Up @@ -276,7 +276,7 @@ static char *xmlnode_msg(xmlNode *xml_node)
}

len = strlen(fmt) + 1;

params[0] = (char *)xmlGetProp(xml_node, (unsigned char *)"param1");
if (params[0])
len += strlen(params[0]);
Expand All @@ -291,7 +291,7 @@ static char *xmlnode_msg(xmlNode *xml_node)
}

strcpy(result, fmt);
free (fmt);
free(fmt);

for (pct = strchr(result, '%'); pct;
(pct = strchr(pct, '%'))) {
Expand Down Expand Up @@ -643,7 +643,7 @@ void free_auth_form(struct oc_auth_form *form)
struct oc_form_opt_select *sel = (void *)form->opts;
int i;

for (i=0; i < sel->nr_choices; i++) {
for (i = 0; i < sel->nr_choices; i++) {
free(sel->choices[i].name);
free(sel->choices[i].label);
free(sel->choices[i].auth_type);
Expand Down
2 changes: 1 addition & 1 deletion compat.c
Expand Up @@ -77,7 +77,7 @@ static int oc_vasprintf(char **strp, const char *fmt, va_list ap)
res = NULL;
goto err;
}
if (len >=0 && len < 160)
if (len >= 0 && len < 160)
goto out;

free(res);
Expand Down
10 changes: 5 additions & 5 deletions cstp.c
Expand Up @@ -171,7 +171,7 @@ static int start_cstp_connection(struct openconnect_info *vpninfo)
vpninfo->vpn_domain = vpninfo->vpn_proxy_pac = NULL;
vpninfo->banner = NULL;

for (i=0; i<3; i++)
for (i = 0; i < 3; i++)
vpninfo->vpn_dns[i] = vpninfo->vpn_nbns[i] = NULL;

for (inc = vpninfo->split_includes; inc; ) {
Expand Down Expand Up @@ -215,12 +215,12 @@ static int start_cstp_connection(struct openconnect_info *vpninfo)
buf_append(buf, sizeof(buf), "X-CSTP-Base-MTU: %d\r\n", base_mtu);
buf_append(buf, sizeof(buf), "X-CSTP-MTU: %d\r\n", mtu);
buf_append(buf, sizeof(buf), "X-CSTP-Address-Type: %s\r\n",
vpninfo->disable_ipv6?"IPv4":"IPv6,IPv4");
vpninfo->disable_ipv6 ? "IPv4" : "IPv6,IPv4");
buf_append(buf, sizeof(buf), "X-DTLS-Master-Secret: ");
for (i = 0; i < sizeof(vpninfo->dtls_secret); i++)
buf_append(buf, sizeof(buf), "%02X", vpninfo->dtls_secret[i]);
buf_append(buf, sizeof(buf), "\r\nX-DTLS-CipherSuite: %s\r\n\r\n",
vpninfo->dtls_ciphers?:"AES256-SHA:AES128-SHA:DES-CBC3-SHA:DES-CBC-SHA");
vpninfo->dtls_ciphers ? : "AES256-SHA:AES128-SHA:DES-CBC3-SHA:DES-CBC-SHA");

openconnect_SSL_write(vpninfo, buf, strlen(buf));

Expand Down Expand Up @@ -715,7 +715,7 @@ int cstp_mainloop(struct openconnect_info *vpninfo, int *timeout)
we should probably remove POLLIN from the events we're looking for,
and add POLLOUT. As it is, though, it'll just chew CPU time in that
fairly unlikely situation, until the write backlog clears. */
while ( (len = cstp_read(vpninfo, buf, sizeof(buf))) > 0) {
while ((len = cstp_read(vpninfo, buf, sizeof(buf))) > 0) {
int payload_len;

if (buf[0] != 'S' || buf[1] != 'T' ||
Expand All @@ -734,7 +734,7 @@ int cstp_mainloop(struct openconnect_info *vpninfo, int *timeout)
continue;
}
vpninfo->ssl_times.last_rx = time(NULL);
switch(buf[6]) {
switch (buf[6]) {
case AC_PKT_DPD_OUT:
vpn_progress(vpninfo, PRG_TRACE,
_("Got CSTP DPD request\n"));
Expand Down
20 changes: 10 additions & 10 deletions dtls.c
Expand Up @@ -112,7 +112,7 @@ int RAND_bytes(char *buf, int len)
#ifdef HAVE_DTLS1_STOP_TIMER
/* OpenSSL doesn't deliberately export this, but we need it to
workaround a DTLS bug in versions < 1.0.0e */
extern void dtls1_stop_timer (SSL *);
extern void dtls1_stop_timer(SSL *);
#endif

#if !defined(NO_BROKEN_DTLS_CHECK) && (OPENSSL_VERSION_NUMBER == 0x10002000L || \
Expand Down Expand Up @@ -265,7 +265,7 @@ int dtls_try_handshake(struct openconnect_info *vpninfo)
#if OPENSSL_VERSION_NUMBER >= 0x1000005fL
/* OpenSSL 1.0.0e or above doesn't resend anyway; do nothing.
However, if we were *built* against 1.0.0e or newer, but at
runtime we find that we are being run against an older
runtime we find that we are being run against an older
version, warn about it. */
if (SSLeay() < 0x1000005fL) {
vpn_progress(vpninfo, PRG_ERR,
Expand All @@ -284,8 +284,8 @@ int dtls_try_handshake(struct openconnect_info *vpninfo)
* so do it manually. This version also works on all
* sane versions of OpenSSL:
*/
memset (&(vpninfo->dtls_ssl->d1->next_timeout), 0,
sizeof((vpninfo->dtls_ssl->d1->next_timeout)));
memset(&(vpninfo->dtls_ssl->d1->next_timeout), 0,
sizeof((vpninfo->dtls_ssl->d1->next_timeout)));
vpninfo->dtls_ssl->d1->timeout_duration = 1;
BIO_ctrl(SSL_get_rbio(vpninfo->dtls_ssl),
BIO_CTRL_DGRAM_SET_NEXT_TIMEOUT, 0,
Expand Down Expand Up @@ -633,10 +633,10 @@ int setup_dtls(struct openconnect_info *vpninfo)
#if defined(OPENCONNECT_GNUTLS) && defined(DTLS_OPENSSL)
/* If we're using GnuTLS for authentication but OpenSSL for DTLS,
we'll need to initialise OpenSSL now... */
SSL_library_init ();
ERR_clear_error ();
SSL_load_error_strings ();
OpenSSL_add_all_algorithms ();
SSL_library_init();
ERR_clear_error();
SSL_load_error_strings();
OpenSSL_add_all_algorithms();
#endif

while (dtls_opt) {
Expand Down Expand Up @@ -726,7 +726,7 @@ int dtls_mainloop(struct openconnect_info *vpninfo, int *timeout)

vpninfo->dtls_times.last_rx = time(NULL);

switch(buf[0]) {
switch (buf[0]) {
case AC_PKT_DATA:
dtls_pkt->len = len - 1;
queue_packet(&vpninfo->incoming_queue, dtls_pkt);
Expand Down Expand Up @@ -884,7 +884,7 @@ int dtls_mainloop(struct openconnect_info *vpninfo, int *timeout)
}
#else /* !HAVE_DTLS */
#warning Your SSL library does not seem to support Cisco DTLS compatibility
int setup_dtls(struct openconnect_info *vpninfo)
int setup_dtls(struct openconnect_info *vpninfo)
{
vpn_progress(vpninfo, PRG_ERR,
_("Built against SSL library with no Cisco DTLS support\n"));
Expand Down
78 changes: 39 additions & 39 deletions gnutls.c
Expand Up @@ -88,7 +88,7 @@ int openconnect_SSL_write(struct openconnect_info *vpninfo, char *buf, size_t le

FD_ZERO(&wr_set);
FD_ZERO(&rd_set);

if (gnutls_record_get_direction(vpninfo->https_sess))
FD_SET(vpninfo->ssl_fd, &wr_set);
else
Expand Down Expand Up @@ -125,7 +125,7 @@ int openconnect_SSL_read(struct openconnect_info *vpninfo, char *buf, size_t len
} else {
FD_ZERO(&wr_set);
FD_ZERO(&rd_set);

if (gnutls_record_get_direction(vpninfo->https_sess))
FD_SET(vpninfo->ssl_fd, &wr_set);
else
Expand Down Expand Up @@ -180,10 +180,10 @@ int openconnect_SSL_gets(struct openconnect_info *vpninfo, char *buf, size_t len
} else {
fd_set rd_set, wr_set;
int maxfd = vpninfo->ssl_fd;

FD_ZERO(&rd_set);
FD_ZERO(&wr_set);

if (gnutls_record_get_direction(vpninfo->https_sess))
FD_SET(vpninfo->ssl_fd, &wr_set);
else
Expand Down Expand Up @@ -434,7 +434,7 @@ static int count_x509_certificates(gnutls_datum_t *datum)
p += 11;
if (!strncmp(p, "CERTIFICATE", 11) ||
!strncmp(p, "X509 CERTIFICATE", 16))
count++;
count++;
}
return count;
}
Expand Down Expand Up @@ -555,7 +555,7 @@ static int assign_privkey(struct openconnect_info *vpninfo,
if (!pcerts)
return GNUTLS_E_MEMORY_ERROR;

for (i=0 ; i < nr_certs; i++) {
for (i = 0 ; i < nr_certs; i++) {
err = gnutls_pcert_import_x509(pcerts + i, certs[i], 0);
if (err) {
vpn_progress(vpninfo, PRG_ERR,
Expand All @@ -572,9 +572,9 @@ static int assign_privkey(struct openconnect_info *vpninfo,
_("Setting PKCS#11 certificate failed: %s\n"),
gnutls_strerror(err));
free_pcerts:
for (i=0 ; i < nr_certs; i++)
for (i = 0 ; i < nr_certs; i++)
gnutls_pcert_deinit(pcerts + i);
free (pcerts);
free(pcerts);
}
return err;
}
Expand Down Expand Up @@ -668,7 +668,7 @@ static int import_openssl_pem(struct openconnect_info *vpninfo,
else if (type == 'R')
begin = "RSA PRIVATE KEY";
else if (type == 'D')
begin = "DSA PRIVATE KEY";
begin = "DSA PRIVATE KEY";
else
return -EINVAL;

Expand Down Expand Up @@ -1123,10 +1123,10 @@ static int load_certificate(struct openconnect_info *vpninfo)
s = sizeof(token->model) + 1;
if (!gnutls_pkcs11_obj_get_info(crt, GNUTLS_PKCS11_OBJ_TOKEN_MODEL,
buf, &s)) {
s--;
memcpy(token->model, buf, s);
memset(token->model + s, ' ',
sizeof(token->model) - s);
s--;
memcpy(token->model, buf, s);
memset(token->model + s, ' ',
sizeof(token->model) - s);
}
}
if (!token->serialNumber[0]) {
Expand Down Expand Up @@ -1322,11 +1322,11 @@ static int load_certificate(struct openconnect_info *vpninfo)
goto out;
}
/* If extra_certs[] is NULL, we have one candidate in 'cert' to check. */
for (i = 0; i < (extra_certs?nr_extra_certs:1); i++) {
for (i = 0; i < (extra_certs ? nr_extra_certs : 1); i++) {
unsigned char cert_id[20];
size_t cert_id_size = sizeof(cert_id);

err = gnutls_x509_crt_get_key_id(extra_certs?extra_certs[i]:cert, 0, cert_id, &cert_id_size);
err = gnutls_x509_crt_get_key_id(extra_certs ? extra_certs[i] : cert, 0, cert_id, &cert_id_size);
if (err)
continue;

Expand Down Expand Up @@ -1369,11 +1369,11 @@ static int load_certificate(struct openconnect_info *vpninfo)
}

/* If extra_certs[] is NULL, we have one candidate in 'cert' to check. */
for (i=0; i < (extra_certs?nr_extra_certs:1); i++) {
for (i = 0; i < (extra_certs ? nr_extra_certs : 1); i++) {
gnutls_pubkey_t pubkey;

gnutls_pubkey_init(&pubkey);
err = gnutls_pubkey_import_x509(pubkey, extra_certs?extra_certs[i]:cert, 0);
err = gnutls_pubkey_import_x509(pubkey, extra_certs ? extra_certs[i] : cert, 0);
if (err) {
vpn_progress(vpninfo, PRG_ERR,
_("Error validating signature against certificate: %s\n"),
Expand Down Expand Up @@ -1461,7 +1461,7 @@ static int load_certificate(struct openconnect_info *vpninfo)
err = gnutls_certificate_get_issuer(vpninfo->https_cred,
last_cert, &issuer, 0);
if (err)
break;
break;

/* The check_issuer_sanity() function works fine as a workaround where
it was used above, but when gnutls_certificate_get_issuer() returns
Expand Down Expand Up @@ -1597,7 +1597,7 @@ static int get_cert_fingerprint(struct openconnect_info *vpninfo,
if (gnutls_x509_crt_get_fingerprint(cert, algo, md, &md_size))
return -EIO;

for (i=0; i < md_size; i++)
for (i = 0; i < md_size; i++)
sprintf(&buf[i*2], "%02X", md[i]);

return 0;
Expand All @@ -1623,11 +1623,11 @@ char *openconnect_get_cert_details(struct openconnect_info *vpninfo,

if (gnutls_x509_crt_print(cert, GNUTLS_CRT_PRINT_FULL, &buf))
return NULL;

/* Just in case gnutls_free() isn't free(), we can't steal it. */
ret = strdup((char *)buf.data);
gnutls_free(buf.data);

return ret;
}

Expand All @@ -1637,7 +1637,7 @@ int openconnect_get_cert_DER(struct openconnect_info *vpninfo,
size_t l = 0;
unsigned char *ret = NULL;

if (gnutls_x509_crt_export(cert, GNUTLS_X509_FMT_DER, ret, &l) !=
if (gnutls_x509_crt_export(cert, GNUTLS_X509_FMT_DER, ret, &l) !=
GNUTLS_E_SHORT_MEMORY_BUFFER)
return -EIO;

Expand All @@ -1647,7 +1647,7 @@ int openconnect_get_cert_DER(struct openconnect_info *vpninfo,

if (gnutls_x509_crt_export(cert, GNUTLS_X509_FMT_DER, ret, &l)) {
free(ret);
return -EIO;
return -EIO;
}
*buf = ret;
return l;
Expand All @@ -1667,7 +1667,7 @@ static int verify_peer(gnutls_session_t session)
vpninfo->peer_cert = NULL;
}

cert_list = gnutls_certificate_get_peers (session, &cert_list_size);
cert_list = gnutls_certificate_get_peers(session, &cert_list_size);
if (!cert_list) {
vpn_progress(vpninfo, PRG_ERR, _("Server presented no certificate\n"));
return GNUTLS_E_CERTIFICATE_ERROR;
Expand All @@ -1677,14 +1677,14 @@ static int verify_peer(gnutls_session_t session)
unsigned char sha1bin[SHA1_SIZE];
char fingerprint[(SHA1_SIZE * 2) + 1];
int i;

err = openconnect_sha1(sha1bin, cert_list[0].data, cert_list[0].size);
if (err) {
vpn_progress(vpninfo, PRG_ERR,
_("Could not calculate SHA1 of server's certificate\n"));
return GNUTLS_E_CERTIFICATE_ERROR;
}
for (i=0; i < SHA1_SIZE; i++)
for (i = 0; i < SHA1_SIZE; i++)
sprintf(&fingerprint[i*2], "%02X", sha1bin[i]);

if (strcasecmp(vpninfo->servercert, fingerprint)) {
Expand All @@ -1695,7 +1695,7 @@ static int verify_peer(gnutls_session_t session)
return 0;
}

err = gnutls_certificate_verify_peers2 (session, &status);
err = gnutls_certificate_verify_peers2(session, &status);
if (err) {
vpn_progress(vpninfo, PRG_ERR, _("Error checking server cert status\n"));
return GNUTLS_E_CERTIFICATE_ERROR;
Expand Down Expand Up @@ -1773,8 +1773,8 @@ int openconnect_open_https(struct openconnect_info *vpninfo)
DEFAULT_SYSTEM_CAFILE,
GNUTLS_X509_FMT_PEM);
#endif
gnutls_certificate_set_verify_function (vpninfo->https_cred,
verify_peer);
gnutls_certificate_set_verify_function(vpninfo->https_cred,
verify_peer);

#ifdef ANDROID_KEYSTORE
if (vpninfo->cafile && !strncmp(vpninfo->cafile, "keystore:", 9)) {
Expand Down Expand Up @@ -1855,20 +1855,20 @@ int openconnect_open_https(struct openconnect_info *vpninfo)
}
}
}
gnutls_init (&vpninfo->https_sess, GNUTLS_CLIENT);
gnutls_session_set_ptr (vpninfo->https_sess, (void *) vpninfo);
gnutls_init(&vpninfo->https_sess, GNUTLS_CLIENT);
gnutls_session_set_ptr(vpninfo->https_sess, (void *) vpninfo);
#if defined(HAVE_TROUSERS) && !defined(HAVE_GNUTLS_CERTIFICATE_SET_KEY)
if (vpninfo->my_pkey == OPENCONNECT_TPM_PKEY)
gnutls_sign_callback_set(vpninfo->https_sess, gtls2_tpm_sign_cb, vpninfo);
#endif

err = gnutls_priority_set_direct (vpninfo->https_sess,
"NORMAL:-VERS-TLS-ALL:+VERS-TLS1.0:"
err = gnutls_priority_set_direct(vpninfo->https_sess,
"NORMAL:-VERS-TLS-ALL:+VERS-TLS1.0:"
#if GNUTLS_VERSION_MAJOR >= 3
"-CURVE-ALL:"
"-CURVE-ALL:"
#endif
"%COMPAT:%DISABLE_SAFE_RENEGOTIATION:%LATEST_RECORD_VERSION",
NULL);
"%COMPAT:%DISABLE_SAFE_RENEGOTIATION:%LATEST_RECORD_VERSION",
NULL);
if (err) {
vpn_progress(vpninfo, PRG_ERR,
_("Failed to set TLS priority string: %s\n"),
Expand All @@ -1879,14 +1879,14 @@ int openconnect_open_https(struct openconnect_info *vpninfo)
return -EIO;
}

gnutls_record_disable_padding (vpninfo->https_sess);
gnutls_credentials_set (vpninfo->https_sess, GNUTLS_CRD_CERTIFICATE, vpninfo->https_cred);
gnutls_record_disable_padding(vpninfo->https_sess);
gnutls_credentials_set(vpninfo->https_sess, GNUTLS_CRD_CERTIFICATE, vpninfo->https_cred);
gnutls_transport_set_ptr(vpninfo->https_sess, /* really? */(gnutls_transport_ptr_t)(long) ssl_sock);

vpn_progress(vpninfo, PRG_INFO, _("SSL negotiation with %s\n"),
vpninfo->hostname);

while ((err = gnutls_handshake (vpninfo->https_sess))) {
while ((err = gnutls_handshake(vpninfo->https_sess))) {
if (err == GNUTLS_E_AGAIN) {
fd_set rd_set, wr_set;
int maxfd = ssl_sock;
Expand Down

0 comments on commit 0450c12

Please sign in to comment.