Skip to content

Commit

Permalink
[#395] Increase SECURITY_BUFFER_SIZE
Browse files Browse the repository at this point in the history
  • Loading branch information
jesperpedersen committed Feb 1, 2024
1 parent 766ca1d commit 9012b55
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/include/pgagroal.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ extern "C" {

#define MAX_BUFFER_SIZE 65535
#define DEFAULT_BUFFER_SIZE 65535
#define SECURITY_BUFFER_SIZE 512
#define SECURITY_BUFFER_SIZE 1024

#define MAX_USERNAME_LENGTH 128
#define MAX_DATABASE_LENGTH 256
Expand Down
14 changes: 14 additions & 0 deletions src/libpgagroal/security.c
Original file line number Diff line number Diff line change
Expand Up @@ -2128,6 +2128,7 @@ server_passthrough(struct message* msg, int auth_type, SSL* c_ssl, int client_fd

if (msg->length > SECURITY_BUFFER_SIZE)
{
pgagroal_log_message(msg);
pgagroal_log_error("Security message too large: %ld", msg->length);
goto error;
}
Expand Down Expand Up @@ -2155,6 +2156,7 @@ server_passthrough(struct message* msg, int auth_type, SSL* c_ssl, int client_fd

if (msg->length > SECURITY_BUFFER_SIZE)
{
pgagroal_log_message(msg);
pgagroal_log_error("Security message too large: %ld", msg->length);
goto error;
}
Expand All @@ -2180,6 +2182,7 @@ server_passthrough(struct message* msg, int auth_type, SSL* c_ssl, int client_fd
{
if (msg->length > SECURITY_BUFFER_SIZE)
{
pgagroal_log_message(msg);
pgagroal_log_error("Security message too large: %ld", msg->length);
goto error;
}
Expand All @@ -2203,6 +2206,7 @@ server_passthrough(struct message* msg, int auth_type, SSL* c_ssl, int client_fd

if (msg->length > SECURITY_BUFFER_SIZE)
{
pgagroal_log_message(msg);
pgagroal_log_error("Security message too large: %ld", msg->length);
goto error;
}
Expand Down Expand Up @@ -2233,6 +2237,7 @@ server_passthrough(struct message* msg, int auth_type, SSL* c_ssl, int client_fd
{
if (msg->length > SECURITY_BUFFER_SIZE)
{
pgagroal_log_message(msg);
pgagroal_log_error("Security message too large: %ld", msg->length);
goto error;
}
Expand Down Expand Up @@ -2321,6 +2326,7 @@ server_authenticate(struct message* msg, int auth_type, char* username, char* pa

if (msg->length > SECURITY_BUFFER_SIZE)
{
pgagroal_log_message(msg);
pgagroal_log_error("Security message too large: %ld", msg->length);
goto error;
}
Expand Down Expand Up @@ -2439,6 +2445,7 @@ server_password(char* username, char* password, int slot, SSL* server_ssl)
status = pgagroal_read_block_message(server_ssl, server_fd, &auth_msg);
if (auth_msg->length > SECURITY_BUFFER_SIZE)
{
pgagroal_log_message(auth_msg);
pgagroal_log_error("Security message too large: %ld", auth_msg->length);
goto error;
}
Expand All @@ -2450,6 +2457,7 @@ server_password(char* username, char* password, int slot, SSL* server_ssl)
{
if (auth_msg->length > SECURITY_BUFFER_SIZE)
{
pgagroal_log_message(auth_msg);
pgagroal_log_error("Security message too large: %ld", auth_msg->length);
goto error;
}
Expand Down Expand Up @@ -2556,6 +2564,7 @@ server_md5(char* username, char* password, int slot, SSL* server_ssl)
status = pgagroal_read_block_message(server_ssl, server_fd, &auth_msg);
if (auth_msg->length > SECURITY_BUFFER_SIZE)
{
pgagroal_log_message(auth_msg);
pgagroal_log_error("Security message too large: %ld", auth_msg->length);
goto error;
}
Expand All @@ -2567,6 +2576,7 @@ server_md5(char* username, char* password, int slot, SSL* server_ssl)
{
if (auth_msg->length > SECURITY_BUFFER_SIZE)
{
pgagroal_log_message(auth_msg);
pgagroal_log_error("Security message too large: %ld", auth_msg->length);
goto error;
}
Expand Down Expand Up @@ -2686,6 +2696,7 @@ server_scram256(char* username, char* password, int slot, SSL* server_ssl)
status = pgagroal_read_block_message(server_ssl, server_fd, &msg);
if (msg->length > SECURITY_BUFFER_SIZE)
{
pgagroal_log_message(msg);
pgagroal_log_error("Security message too large: %ld", msg->length);
goto error;
}
Expand Down Expand Up @@ -2750,6 +2761,7 @@ server_scram256(char* username, char* password, int slot, SSL* server_ssl)
status = pgagroal_read_block_message(server_ssl, server_fd, &msg);
if (msg->length > SECURITY_BUFFER_SIZE)
{
pgagroal_log_message(msg);
pgagroal_log_error("Security message too large: %ld", msg->length);
goto error;
}
Expand Down Expand Up @@ -5004,6 +5016,7 @@ auth_query_server_md5(struct message* startup_response_msg, char* username, char
status = pgagroal_read_block_message(server_ssl, socket, &auth_msg);
if (auth_msg->length > SECURITY_BUFFER_SIZE)
{
pgagroal_log_message(auth_msg);
pgagroal_log_error("Security message too large: %ld", auth_msg->length);
goto error;
}
Expand All @@ -5015,6 +5028,7 @@ auth_query_server_md5(struct message* startup_response_msg, char* username, char
{
if (auth_msg->length > SECURITY_BUFFER_SIZE)
{
pgagroal_log_message(auth_msg);
pgagroal_log_error("Security message too large: %ld", auth_msg->length);
goto error;
}
Expand Down

0 comments on commit 9012b55

Please sign in to comment.