Skip to content

Commit

Permalink
Proper size and initialisation for array data
Browse files Browse the repository at this point in the history
  • Loading branch information
DimitriPapadopoulos committed Jul 22, 2024
1 parent a6fe5cb commit 1d94ad9
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions src/http.c
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,30 @@ int auth_log_in(struct tunnel *tunnel)
char portal[64] = { '\0' };
char magic[32] = {'\0' };
char peer[32] = { '\0' };
char data[9 + 3 * USERNAME_SIZE + 12 + 3 * PASSWORD_SIZE + 7 + 3 * REALM_SIZE + 7 + 1];
#define OFV_MAX(a,b) ((a) > (b) ? a : b)
char data[
OFV_MAX(
// username=USERNAME&realm=REALM&ajax=1&redir=%%2Fremote%%2Findex&just_logged_in=1
(
sizeof("username=") +
3 * USERNAME_SIZE +
sizeof("realm=") +
3 * REALM_SIZE +
sizeof("ajax=1&redir=%%2Fremote%%2Findex&just_logged_in=1")
),
// "username=USERNAME&credential=PASSWORD&realm=REALM&ajax=1
(
sizeof("username=") +
3 * USERNAME_SIZE +
sizeof("realm=") +
3 * REALM_SIZE +
sizeof("credential=") +
3 * PASSWORD_SIZE +
sizeof("ajax=1")
)
)
] = { '\0' };
#undef OFV_MAX
char token[128], tokenresponse[256], tokenparams[320];
char action_url[1024] = { '\0' };
char *res = NULL;
Expand All @@ -651,7 +674,6 @@ int auth_log_in(struct tunnel *tunnel)
tunnel->cookie[0] = '\0';

if (username[0] == '\0' && tunnel->config->password[0] == '\0') {
snprintf(data, sizeof(data), "");
ret = http_request(tunnel, "GET", "/remote/login",
data, &res, &response_size);
} else {
Expand Down

0 comments on commit 1d94ad9

Please sign in to comment.