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

mod_radius: copy _only_ the password #1285

Merged
merged 1 commit into from Aug 5, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 8 additions & 3 deletions contrib/mod_radius.c
Expand Up @@ -2324,21 +2324,26 @@ static void radius_add_passwd(radius_packet_t *packet, unsigned char type,

pwlen = strlen((const char *) passwd);

/* Clear the buffers. */
memset(pwhash, '\0', sizeof(pwhash));

if (pwlen == 0) {
pwlen = RADIUS_PASSWD_LEN;

} if ((pwlen & (RADIUS_PASSWD_LEN - 1)) != 0) {
/* pwlen is not a multiple of RADIUS_PASSWD_LEN, need to prepare a proper buffer */
memcpy(pwhash, passwd, pwlen);

/* Round up the length. */
pwlen += (RADIUS_PASSWD_LEN - 1);

/* Truncate the length, as necessary. */
pwlen &= ~(RADIUS_PASSWD_LEN - 1);
} else {
/* pwlen is a multiple of RADIUS_PASSWD_LEN, we can just use it. */
memcpy(pwhash, passwd, pwlen);
}

/* Clear the buffers. */
memset(pwhash, '\0', sizeof(pwhash));
memcpy(pwhash, passwd, pwlen);

/* Find the password attribute. */
attrib = radius_get_attrib(packet, RADIUS_PASSWORD);
Expand Down