summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Standring <me@justinstandring.com>2016-12-01 14:44:29 -0800
committerJustin Standring <me@justinstandring.com>2016-12-01 14:51:21 -0800
commitac2c16774be593ebaa769b09c95722d08216cb95 (patch)
tree276015358b8d1977b1f7860fb140ec4f1051dea6
parent1bff76afb3b893bb941762419daa2a14657c3b71 (diff)
downloadlibpam-radius-auth-ac2c16774be593ebaa769b09c95722d08216cb95.tar.gz
libpam-radius-auth-ac2c16774be593ebaa769b09c95722d08216cb95.zip
Copy password to buffer before rounding length
-rw-r--r--src/pam_radius_auth.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/pam_radius_auth.c b/src/pam_radius_auth.c
index e9b3034..34b2a38 100644
--- a/src/pam_radius_auth.c
+++ b/src/pam_radius_auth.c
@@ -528,6 +528,9 @@ static void add_password(AUTH_HDR *request, unsigned char type, CONST char *pass
length = MAXPASS;
}
+ memcpy(hashed, password, length);
+ memset(hashed + length, 0, sizeof(hashed) - length);
+
if (length == 0) {
length = AUTH_PASS_LEN; /* 0 maps to 16 */
} if ((length & (AUTH_PASS_LEN - 1)) != 0) {
@@ -535,9 +538,6 @@ static void add_password(AUTH_HDR *request, unsigned char type, CONST char *pass
length &= ~(AUTH_PASS_LEN - 1); /* chop it off */
} /* 16*N maps to itself */
- memcpy(hashed, password, length);
- memset(hashed + length, 0, sizeof(hashed) - length);
-
attr = find_attribute(request, PW_PASSWORD);
if (type == PW_PASSWORD) {