Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit d05fb6e

Browse files
[[ PostgreSQL SSL ]] Updated to make sure we don't mutate any args passed to revdb connect.
1 parent 3bdbcf6 commit d05fb6e

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

revdb/src/postgresql_connection.cpp

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -88,23 +88,25 @@ Bool DBConnection_POSTGRESQL::connect(char **args, int numargs)
8888
t_delimiter = strchr(args[i], '=');
8989
if (t_delimiter != NULL)
9090
{
91-
*t_delimiter = '\0';
9291
t_ssl_opt_key = args[i];
93-
t_ssl_opt_val = (t_delimiter + (1 * sizeof(char)));
92+
t_ssl_opt_val = (t_delimiter + sizeof(char));
93+
94+
size_t t_key_length;
95+
t_key_length = (size_t)(t_delimiter - args[i]);
9496

9597
if (*t_ssl_opt_val != '\0')
9698
{
97-
if (strcmp(t_ssl_opt_key, "sslmode") == 0)
99+
if (strncmp(t_ssl_opt_key, "sslmode", t_key_length) == 0)
98100
t_sslmode = t_ssl_opt_val;
99-
else if (strcmp(t_ssl_opt_key, "sslcompression") == 0)
101+
else if (strncmp(t_ssl_opt_key, "sslcompression", t_key_length) == 0)
100102
t_sslcompression = t_ssl_opt_val;
101-
else if (strcmp(t_ssl_opt_key, "sslcert") == 0)
103+
else if (strncmp(t_ssl_opt_key, "sslcert", t_key_length) == 0)
102104
t_sslcert = t_ssl_opt_val;
103-
else if (strcmp(t_ssl_opt_key, "sslkey") == 0)
105+
else if (strncmp(t_ssl_opt_key, "sslkey", t_key_length) == 0)
104106
t_sslkey = t_ssl_opt_val;
105-
else if (strcmp(t_ssl_opt_key, "sslrootcert") == 0)
107+
else if (strncmp(t_ssl_opt_key, "sslrootcert", t_key_length) == 0)
106108
t_sslrootcert = t_ssl_opt_val;
107-
else if (strcmp(t_ssl_opt_key, "sslcrl") == 0)
109+
else if (strncmp(t_ssl_opt_key, "sslcrl", t_key_length) == 0)
108110
t_sslcrl = t_ssl_opt_val;
109111
}
110112
}

0 commit comments

Comments
 (0)