summaryrefslogtreecommitdiff
path: root/modules/pam_xauth
diff options
context:
space:
mode:
authorDmitry V. Levin <ldv@altlinux.org>2020-03-16 21:02:18 +0000
committerDmitry V. Levin <ldv@altlinux.org>2020-03-19 18:40:16 +0000
commit1181e0590c9f059c40b71718d4fb3b6c339f65db (patch)
tree96da444742d360992e91d6f937e461892ff5f1c0 /modules/pam_xauth
parenta8b4dce7b53d73de372e150028c970ee0a2a2e97 (diff)
Use PAM_ARRAY_SIZE
Replace all instances of sizeof(x) / sizeof(*x) with PAM_ARRAY_SIZE(x) which is less error-prone and implements an additional type check. * libpam/pam_handlers.c: Include "pam_inline.h". (_pam_open_config_file): Use PAM_ARRAY_SIZE. * modules/pam_exec/pam_exec.c: Include "pam_inline.h". (call_exec): Use PAM_ARRAY_SIZE. * modules/pam_namespace/pam_namespace.c: Include "pam_inline.h". (filter_mntopts): Use PAM_ARRAY_SIZE. * modules/pam_timestamp/hmacfile.c: Include "pam_inline.h". (testvectors): Use PAM_ARRAY_SIZE. * modules/pam_xauth/pam_xauth.c: Include "pam_inline.h". (run_coprocess, pam_sm_open_session): Use PAM_ARRAY_SIZE. * tests/tst-pam_get_item.c: Include "pam_inline.h". (main): Use PAM_ARRAY_SIZE. * tests/tst-pam_set_item.c: Likewise. * xtests/tst-pam_pwhistory1.c: Likewise. * xtests/tst-pam_time1.c: Likewise.
Diffstat (limited to 'modules/pam_xauth')
-rw-r--r--modules/pam_xauth/pam_xauth.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/modules/pam_xauth/pam_xauth.c b/modules/pam_xauth/pam_xauth.c
index ea99bb03..f74a0c98 100644
--- a/modules/pam_xauth/pam_xauth.c
+++ b/modules/pam_xauth/pam_xauth.c
@@ -64,6 +64,7 @@
#endif
#include "pam_cc_compat.h"
+#include "pam_inline.h"
#define DATANAME "pam_xauth_cookie_file"
#define XAUTHENV "XAUTHORITY"
@@ -172,7 +173,7 @@ run_coprocess(pam_handle_t *pamh, const char *input, char **output,
/* Convert the varargs list into a regular array of strings. */
va_start(ap, command);
args[0] = command;
- for (j = 1; j < ((sizeof(args) / sizeof(args[0])) - 1); j++) {
+ for (j = 1; j < PAM_ARRAY_SIZE(args) - 1; j++) {
args[j] = va_arg(ap, const char*);
if (args[j] == NULL) {
break;
@@ -399,7 +400,7 @@ pam_sm_open_session (pam_handle_t *pamh, int flags UNUSED,
if (xauth == NULL) {
size_t j;
- for (j = 0; j < sizeof(xauthpaths)/sizeof(xauthpaths[0]); j++) {
+ for (j = 0; j < PAM_ARRAY_SIZE(xauthpaths); j++) {
if (access(xauthpaths[j], X_OK) == 0) {
xauth = xauthpaths[j];
break;