summaryrefslogtreecommitdiff
path: root/libpam
diff options
context:
space:
mode:
authorDmitry V. Levin <ldv@altlinux.org>2020-07-14 08:00:00 +0000
committerDmitry V. Levin <ldv@altlinux.org>2020-07-15 08:05:07 +0000
commit40513560a03d51923cfa717d1360ec9f351a6775 (patch)
treee01ec8cffdadcb1be073e3e7051fdabb90b24e5c /libpam
parent48f44125fac8873237ade9e94942f82a8e6d6e1d (diff)
pam_inline.h: cleanup pam_read_passwords a bit
* libpam/include/pam_inline.h (pam_read_passwords): Increment pptr once instead of using pptr+1 several times. This change is not expected to affect the code generated by the compiler as the latter is likely to perform the optimization itself.
Diffstat (limited to 'libpam')
-rw-r--r--libpam/include/pam_inline.h11
1 files changed, 6 insertions, 5 deletions
diff --git a/libpam/include/pam_inline.h b/libpam/include/pam_inline.h
index 8040b865..ec2f3bf0 100644
--- a/libpam/include/pam_inline.h
+++ b/libpam/include/pam_inline.h
@@ -90,17 +90,18 @@ pam_read_passwords(int fd, int npass, char **passwords)
break;
}
- while (npass > 0 && (pptr=memchr(passwords[i]+offset, '\0', rbytes))
- != NULL) {
- rbytes -= pptr - (passwords[i]+offset) + 1;
+ while (npass > 0 &&
+ (pptr = memchr(passwords[i] + offset, '\0', rbytes)) != NULL) {
+ ++pptr; /* skip the '\0' */
+ rbytes -= pptr - (passwords[i] + offset);
i++;
offset = 0;
npass--;
if (rbytes > 0) {
if (npass > 0) {
- memcpy(passwords[i], pptr+1, rbytes);
+ memcpy(passwords[i], pptr, rbytes);
}
- memset(pptr+1, '\0', rbytes);
+ memset(pptr, '\0', rbytes);
}
}
offset += rbytes;