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 cfdc144
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions src/http.c
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,28 @@ 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 +672,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
Empty file modified tests/ci/checkpatch/checkpatch.pl
100644 → 100755
Empty file.

0 comments on commit cfdc144

Please sign in to comment.