diff options
Diffstat (limited to 'src/interfaces')
-rw-r--r-- | src/interfaces/libpq/fe-auth-scram.c | 2 | ||||
-rw-r--r-- | src/interfaces/libpq/fe-connect.c | 80 | ||||
-rw-r--r-- | src/interfaces/libpq/fe-secure-openssl.c | 51 | ||||
-rw-r--r-- | src/interfaces/libpq/libpq-fe.h | 4 |
4 files changed, 70 insertions, 67 deletions
diff --git a/src/interfaces/libpq/fe-auth-scram.c b/src/interfaces/libpq/fe-auth-scram.c index d8a5bbc712a..fbb44b3f852 100644 --- a/src/interfaces/libpq/fe-auth-scram.c +++ b/src/interfaces/libpq/fe-auth-scram.c @@ -228,7 +228,7 @@ pg_fe_scram_exchange(void *opaq, char *input, int inputlen, { *success = false; printfPQExpBuffer(errorMessage, - libpq_gettext("invalid server signature\n")); + libpq_gettext("invalid server signature\n")); } *done = true; state->state = FE_SCRAM_FINISHED; diff --git a/src/interfaces/libpq/fe-connect.c b/src/interfaces/libpq/fe-connect.c index 4dc892402d3..02b7358acab 100644 --- a/src/interfaces/libpq/fe-connect.c +++ b/src/interfaces/libpq/fe-connect.c @@ -37,7 +37,7 @@ #endif #define near #include <shlobj.h> -#ifdef _MSC_VER /* mstcpip.h is missing on mingw */ +#ifdef _MSC_VER /* mstcpip.h is missing on mingw */ #include <mstcpip.h> #endif #else @@ -786,7 +786,7 @@ connectOptions2(PGconn *conn) if ((conn->pghostaddr == NULL || conn->pghostaddr[0] == '\0') && conn->pghost != NULL) { - char *s; + char *s; for (s = conn->pghost; *s != '\0'; ++s) if (*s == ',') @@ -798,8 +798,8 @@ connectOptions2(PGconn *conn) goto oom_error; /* - * We now have one pg_conn_host structure per possible host. Fill in - * the host details for each one. + * We now have one pg_conn_host structure per possible host. Fill in the + * host details for each one. */ if (conn->pghostaddr != NULL && conn->pghostaddr[0] != '\0') { @@ -810,12 +810,12 @@ connectOptions2(PGconn *conn) } else if (conn->pghost != NULL && conn->pghost[0] != '\0') { - int i = 0; - char *s = conn->pghost; + int i = 0; + char *s = conn->pghost; while (1) { - char *e = s; + char *e = s; /* * Search for the end of the current hostname; a comma or @@ -864,13 +864,13 @@ connectOptions2(PGconn *conn) */ if (conn->pgport != NULL && conn->pgport[0] != '\0') { - int i = 0; - char *s = conn->pgport; - int nports = 1; + int i = 0; + char *s = conn->pgport; + int nports = 1; for (i = 0; i < conn->nconnhost; ++i) { - char *e = s; + char *e = s; /* Search for the end of the current port number. */ while (*e != '\0' && *e != ',') @@ -891,9 +891,8 @@ connectOptions2(PGconn *conn) } /* - * Move on to the next port number, unless there are no more. - * (If only one part number is specified, we reuse it for every - * host.) + * Move on to the next port number, unless there are no more. (If + * only one part number is specified, we reuse it for every host.) */ if (*e != '\0') { @@ -911,7 +910,7 @@ connectOptions2(PGconn *conn) { conn->status = CONNECTION_BAD; printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("could not match %d port numbers to %d hosts\n"), + libpq_gettext("could not match %d port numbers to %d hosts\n"), nports, conn->nconnhost); return false; } @@ -947,12 +946,12 @@ connectOptions2(PGconn *conn) } /* - * Supply default password if none given. Note that the password might - * be different for each host/port pair. + * Supply default password if none given. Note that the password might be + * different for each host/port pair. */ if (conn->pgpass == NULL || conn->pgpass[0] == '\0') { - int i; + int i; if (conn->pgpassfile == NULL || conn->pgpassfile[0] == '\0') { @@ -979,10 +978,11 @@ connectOptions2(PGconn *conn) for (i = 0; i < conn->nconnhost; i++) { /* - * Try to get a password for this host from pgpassfile. We use host - * name rather than host address in the same manner to PQhost(). + * Try to get a password for this host from pgpassfile. We use + * host name rather than host address in the same manner to + * PQhost(). */ - char *pwhost = conn->connhost[i].host; + char *pwhost = conn->connhost[i].host; if (conn->connhost[i].type == CHT_HOST_ADDRESS && conn->pghost != NULL && conn->pghost[0] != '\0') @@ -1070,7 +1070,7 @@ connectOptions2(PGconn *conn) { conn->status = CONNECTION_BAD; printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("invalid target_session_attrs value: \"%s\"\n"), + libpq_gettext("invalid target_session_attrs value: \"%s\"\n"), conn->target_session_attrs); return false; } @@ -1641,8 +1641,8 @@ connectDBStart(PGconn *conn) { appendPQExpBuffer(&conn->errorMessage, libpq_gettext("Unix-domain socket path \"%s\" is too long (maximum %d bytes)\n"), - portstr, - (int) (UNIXSOCK_PATH_BUFLEN - 1)); + portstr, + (int) (UNIXSOCK_PATH_BUFLEN - 1)); conn->options_valid = false; goto connect_errReturn; } @@ -2833,12 +2833,12 @@ keep_going: /* We will come back to here until there is strcmp(conn->target_session_attrs, "read-write") == 0) { /* - * We are yet to make a connection. Save all existing error - * messages until we make a successful connection state. - * This is important because PQsendQuery is going to reset - * conn->errorMessage and we will lose error messages - * related to previous hosts we have tried to connect and - * failed. + * We are yet to make a connection. Save all existing + * error messages until we make a successful connection + * state. This is important because PQsendQuery is going + * to reset conn->errorMessage and we will lose error + * messages related to previous hosts we have tried to + * connect and failed. */ if (!saveErrorMessage(conn, &savedMessage)) goto error_return; @@ -3006,8 +3006,8 @@ keep_going: /* We will come back to here until there is release_all_addrinfo(conn); /* - * Finish reading any remaining messages before - * being considered as ready. + * Finish reading any remaining messages before being + * considered as ready. */ conn->status = CONNECTION_CONSUME; goto keep_going; @@ -5211,8 +5211,8 @@ conninfo_uri_parse_options(PQconninfoOption *options, const char *uri, char *user = NULL; char *host = NULL; bool retval = false; - PQExpBufferData hostbuf; - PQExpBufferData portbuf; + PQExpBufferData hostbuf; + PQExpBufferData portbuf; initPQExpBuffer(&hostbuf); initPQExpBuffer(&portbuf); @@ -5349,8 +5349,8 @@ conninfo_uri_parse_options(PQconninfoOption *options, const char *uri, host = p; /* - * Look for port specifier (colon) or end of host specifier (slash) - * or query (question mark) or host separator (comma). + * Look for port specifier (colon) or end of host specifier + * (slash) or query (question mark) or host separator (comma). */ while (*p && *p != ':' && *p != '/' && *p != '?' && *p != ',') ++p; @@ -5364,7 +5364,7 @@ conninfo_uri_parse_options(PQconninfoOption *options, const char *uri, if (prevchar == ':') { - const char *port = ++p; /* advance past host terminator */ + const char *port = ++p; /* advance past host terminator */ while (*p && *p != '/' && *p != '?' && *p != ',') ++p; @@ -5377,7 +5377,7 @@ conninfo_uri_parse_options(PQconninfoOption *options, const char *uri, if (prevchar != ',') break; - ++p; /* advance past comma separator */ + ++p; /* advance past comma separator */ appendPQExpBufferStr(&hostbuf, ","); appendPQExpBufferStr(&portbuf, ","); } @@ -5850,7 +5850,7 @@ PQuser(const PGconn *conn) char * PQpass(const PGconn *conn) { - char *password = NULL; + char *password = NULL; if (!conn) return NULL; @@ -6000,7 +6000,7 @@ PQbackendPID(const PGconn *conn) int PQconnectionNeedsPassword(const PGconn *conn) { - char *password; + char *password; if (!conn) return false; diff --git a/src/interfaces/libpq/fe-secure-openssl.c b/src/interfaces/libpq/fe-secure-openssl.c index 101d63899c8..a7c3d7af64e 100644 --- a/src/interfaces/libpq/fe-secure-openssl.c +++ b/src/interfaces/libpq/fe-secure-openssl.c @@ -129,8 +129,8 @@ pgtls_open_client(PGconn *conn) if (conn->ssl == NULL) { /* - * Create a connection-specific SSL object, and load client certificate, - * private key, and trusted CA certs. + * Create a connection-specific SSL object, and load client + * certificate, private key, and trusted CA certs. */ if (initialize_SSL(conn) != 0) { @@ -868,8 +868,8 @@ destroy_ssl_system(void) CRYPTO_set_id_callback(NULL); /* - * We don't free the lock array. If we get another connection in - * this process, we will just re-use them with the existing mutexes. + * We don't free the lock array. If we get another connection in this + * process, we will just re-use them with the existing mutexes. * * This means we leak a little memory on repeated load/unload of the * library. @@ -889,7 +889,7 @@ destroy_ssl_system(void) static int initialize_SSL(PGconn *conn) { - SSL_CTX *SSL_context; + SSL_CTX *SSL_context; struct stat buf; char homedir[MAXPGPATH]; char fnbuf[MAXPGPATH]; @@ -916,8 +916,8 @@ initialize_SSL(PGconn *conn) * Create a new SSL_CTX object. * * We used to share a single SSL_CTX between all connections, but it was - * complicated if connections used different certificates. So now we create - * a separate context for each connection, and accept the overhead. + * complicated if connections used different certificates. So now we + * create a separate context for each connection, and accept the overhead. */ SSL_context = SSL_CTX_new(SSLv23_method()); if (!SSL_context) @@ -925,8 +925,8 @@ initialize_SSL(PGconn *conn) char *err = SSLerrmessage(ERR_get_error()); printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("could not create SSL context: %s\n"), - err); + libpq_gettext("could not create SSL context: %s\n"), + err); SSLerrfree(err); return -1; } @@ -935,8 +935,8 @@ initialize_SSL(PGconn *conn) SSL_CTX_set_options(SSL_context, SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3); /* - * Disable OpenSSL's moving-write-buffer sanity check, because it - * causes unnecessary failures in nonblocking send cases. + * Disable OpenSSL's moving-write-buffer sanity check, because it causes + * unnecessary failures in nonblocking send cases. */ SSL_CTX_set_mode(SSL_context, SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER); @@ -1064,8 +1064,8 @@ initialize_SSL(PGconn *conn) { /* * Cert file exists, so load it. Since OpenSSL doesn't provide the - * equivalent of "SSL_use_certificate_chain_file", we have to load - * it into the SSL context, rather than the SSL object. + * equivalent of "SSL_use_certificate_chain_file", we have to load it + * into the SSL context, rather than the SSL object. */ if (SSL_CTX_use_certificate_chain_file(SSL_context, fnbuf) != 1) { @@ -1084,10 +1084,11 @@ initialize_SSL(PGconn *conn) } /* - * The SSL context is now loaded with the correct root and client certificates. - * Create a connection-specific SSL object. The private key is loaded directly - * into the SSL object. (We could load the private key into the context, too, but - * we have done it this way historically, and it doesn't really matter.) + * The SSL context is now loaded with the correct root and client + * certificates. Create a connection-specific SSL object. The private key + * is loaded directly into the SSL object. (We could load the private key + * into the context, too, but we have done it this way historically, and + * it doesn't really matter.) */ if (!(conn->ssl = SSL_new(SSL_context)) || !SSL_set_app_data(conn->ssl, conn) || @@ -1105,9 +1106,9 @@ initialize_SSL(PGconn *conn) conn->ssl_in_use = true; /* - * SSL contexts are reference counted by OpenSSL. We can free it as soon as we - * have created the SSL object, and it will stick around for as long as it's - * actually needed. + * SSL contexts are reference counted by OpenSSL. We can free it as soon + * as we have created the SSL object, and it will stick around for as long + * as it's actually needed. */ SSL_CTX_free(SSL_context); SSL_context = NULL; @@ -1269,7 +1270,8 @@ initialize_SSL(PGconn *conn) } /* - * If a root cert was loaded, also set our certificate verification callback. + * If a root cert was loaded, also set our certificate verification + * callback. */ if (have_rootcert) SSL_set_verify(conn->ssl, SSL_VERIFY_PEER, verify_cb); @@ -1647,9 +1649,10 @@ my_BIO_s_socket(void) my_bio_methods = BIO_meth_new(my_bio_index, "libpq socket"); if (!my_bio_methods) return NULL; + /* - * As of this writing, these functions never fail. But check anyway, like - * OpenSSL's own examples do. + * As of this writing, these functions never fail. But check anyway, + * like OpenSSL's own examples do. */ if (!BIO_meth_set_write(my_bio_methods, my_sock_write) || !BIO_meth_set_read(my_bio_methods, my_sock_read) || @@ -1657,7 +1660,7 @@ my_BIO_s_socket(void) !BIO_meth_set_puts(my_bio_methods, BIO_meth_get_puts(biom)) || !BIO_meth_set_ctrl(my_bio_methods, BIO_meth_get_ctrl(biom)) || !BIO_meth_set_create(my_bio_methods, BIO_meth_get_create(biom)) || - !BIO_meth_set_destroy(my_bio_methods, BIO_meth_get_destroy(biom)) || + !BIO_meth_set_destroy(my_bio_methods, BIO_meth_get_destroy(biom)) || !BIO_meth_set_callback_ctrl(my_bio_methods, BIO_meth_get_callback_ctrl(biom))) { BIO_meth_free(my_bio_methods); diff --git a/src/interfaces/libpq/libpq-fe.h b/src/interfaces/libpq/libpq-fe.h index 093c4986d8c..e7496c59db3 100644 --- a/src/interfaces/libpq/libpq-fe.h +++ b/src/interfaces/libpq/libpq-fe.h @@ -65,8 +65,8 @@ typedef enum CONNECTION_NEEDED, /* Internal state: connect() needed */ CONNECTION_CHECK_WRITABLE, /* Check if we could make a writable * connection. */ - CONNECTION_CONSUME /* Wait for any pending message and - * consume them. */ + CONNECTION_CONSUME /* Wait for any pending message and consume + * them. */ } ConnStatusType; typedef enum |