On Mon, Mar 19, 2018 at 8:19 AM, William Roberts <bill.c.roberts@xxxxxxxxx> wrote: > On Mon, Mar 19, 2018 at 7:46 AM, Vit Mojzis <vmojzis@xxxxxxxxxx> wrote: >> Fix sizeof calculation in array iteration introduced by commit >> 6bb8282c4cf66e93daa9684dbe9c75bb6b1e09a7 >> "libsemanage: replace access() checks to make setuid programs work" >> >> Signed-off-by: Vit Mojzis <vmojzis@xxxxxxxxxx> >> --- >> libsemanage/src/direct_api.c | 3 ++- >> 1 file changed, 2 insertions(+), 1 deletion(-) >> >> diff --git a/libsemanage/src/direct_api.c b/libsemanage/src/direct_api.c >> index 439122df..e7ec952f 100644 >> --- a/libsemanage/src/direct_api.c >> +++ b/libsemanage/src/direct_api.c >> @@ -60,6 +60,7 @@ >> >> #define PIPE_READ 0 >> #define PIPE_WRITE 1 >> +#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) >> >> static void semanage_direct_destroy(semanage_handle_t * sh); >> static int semanage_direct_disconnect(semanage_handle_t * sh); >> @@ -1332,7 +1333,7 @@ static int semanage_direct_commit(semanage_handle_t * sh) >> SEMANAGE_SEUSERS_LINKED, >> SEMANAGE_USERS_EXTRA_LINKED}; >> >> - for (i = 0; i < (int) sizeof(files); i++) { >> + for (i = 0; i < (int) ARRAY_SIZE(files); i++) { >> path = semanage_path(SEMANAGE_TMP, files[i]); >> if (stat(path, &sb) != 0) { >> if (errno != ENOENT) { >> -- >> 2.14.3 >> >> > ack Thanks, merged: https://github.com/SELinuxProject/selinux/pull/87 > > Just noticing: that code has i as an int, which it probably should be size_t and > the files array as an array of int's, it should probably use the > enum type.