Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix memory leaks in duo.c #295

Merged
merged 1 commit into from
Oct 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions lib/duo.c
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,7 @@ duo_login(struct duo_ctx *ctx, const char *username,
const char *client_ip, int flags, const char *command, const int failmode)
{
duo_code_t ret;
int size;
char buf[256];
char *pushinfo = NULL;
char p[256];
Expand Down Expand Up @@ -599,13 +600,23 @@ duo_login(struct duo_ctx *ctx, const char *username,
}

/* Add pushinfo parameters */
char *encoded_command = urlenc_encode(command);
if (encoded_command == NULL) {
return (DUO_LIB_ERROR);
}

local_ip = duo_local_ip();
if (asprintf(&pushinfo, "Server+IP=%s&Command=%s",
local_ip, command ? urlenc_encode(command) : "") < 0 ||
duo_add_param(ctx, "pushinfo", pushinfo) != DUO_OK) {
size = asprintf(&pushinfo, "Server+IP=%s&Command=%s", local_ip, encoded_command);
free(encoded_command);
if (size < 0) {
return (DUO_LIB_ERROR);
}

ret = duo_add_param(ctx, "pushinfo", pushinfo);
free(pushinfo);
if (ret != DUO_OK) {
return (DUO_LIB_ERROR);
}

/* Try Duo authentication. Only use the configured timeout if
* the call is asynchronous, because async calls should return
Expand Down Expand Up @@ -694,8 +705,10 @@ duo_login(struct duo_ctx *ctx, const char *username,
result);
ret = DUO_SERVER_ERROR;
}
_JSON_VALUE_FREE(json_new);
break;
}
_JSON_VALUE_FREE(json_new);
}
_JSON_VALUE_FREE(json);
return (ret);
Expand Down
Loading