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

libsemanage: fix src/genhomedircon.c build on gcc-14 (`-Werror=allo… #414

Closed
wants to merge 1 commit into from
Closed

Conversation

trofi
Copy link
Contributor

@trofi trofi commented Dec 1, 2023

…c-size`)

gcc-14 added a new -Walloc-size warning that makes sure that size of an individual element matches size of a pointed type:

https://gcc.gnu.org/PR71219

libsemanage triggers it on calloc() calls where member size is used as 1 (instead of member count):

genhomedircon.c: In function 'ignore_setup':
genhomedircon.c:152:21:
  error: allocation of insufficient size '1' for type 'ignoredir_t'
    {aka 'struct IgnoreDir'} with size '16' [-Werror=alloc-size]
  152 |                 ptr = calloc(sizeof(ignoredir_t),1);
      |                     ^

…c-size`)

`gcc-14` added a new `-Walloc-size` warning that makes sure that size of
an individual element matches size of a pointed type:

    https://gcc.gnu.org/PR71219

`libsemanage` triggers it on `calloc()` calls where member size is used
as `1` (instead of member count):

    genhomedircon.c: In function 'ignore_setup':
    genhomedircon.c:152:21:
      error: allocation of insufficient size '1' for type 'ignoredir_t'
        {aka 'struct IgnoreDir'} with size '16' [-Werror=alloc-size]
      152 |                 ptr = calloc(sizeof(ignoredir_t),1);
          |                     ^

Signed-off-by: Sergei Trofimovich <[email protected]>
@jwcart2
Copy link
Contributor

jwcart2 commented Dec 4, 2023

Thank you for the patch!

For your patch to be reviewed and accepted it must be sent to the [email protected] mailing list. You can use git send-email to do that.

It looks like there are multiple places throughout the SELinux userspace where the number of elements and size of an element are swapped in a calloc call.

Thanks again,
Jim

@trofi
Copy link
Contributor Author

trofi commented Dec 4, 2023

Sent the patch as https://lore.kernel.org/selinux/[email protected]/T/#u . Will send more if I get to other components.

Thank you Jim!

@trofi trofi closed this by deleting the head repository Jan 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants