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

print_indent prototype missing from header #6

Closed
polkit-github-migration-bot opened this issue May 10, 2016 · 1 comment · Fixed by #428
Closed

print_indent prototype missing from header #6

polkit-github-migration-bot opened this issue May 10, 2016 · 1 comment · Fixed by #428

Comments

@polkit-github-migration-bot
Copy link
Collaborator

In gitlab.freedesktop.org by bugzilla-migration on May 10, 2016, 23:36

Link to the original issue: https://gitlab.freedesktop.org/polkit/polkit/-/issues/5

Submitted by Brant Gurganus

Assigned to David Zeuthen @david

Link to original bug (#95342)

Description

The print_indent prototype is missing from the root/test/mocklibc/src/netgroup.h header. Because of the FILE definition being used, <stdio.h> also needs included.

The compilation affected is that of mocklibc-debug-netgroup. Currently that uses print_included without a formal prototype to ensure consistency between the implementation from netgroup.c and the usage in netgroup-debug.c. Without a proper prototype, the C compiler must guess at the calling convention which can be dangerous.

Again, this can be addressed by adding the <stdio.h> include and the print_include prototype to netgroup.h.

@polkit-github-migration-bot
Copy link
Collaborator Author

In gitlab.freedesktop.org by bugzilla-migration on May 11, 2016, 15:57

💬 Miloslav Trmac said:

Yes.

Or rather, the prototype should not be added into src/netgroup.h (a substitute for the public <netgroup.h>); it should be a private header file of mocklibc.

But it seems by far simplest to move the definition from netgroup.c to netgroup-debug.c, the only user; then we can make it static.

Would you like to provide a tested patch?

vmihalko added a commit to vmihalko/polkit that referenced this issue Mar 8, 2024
This fixes build error with GCC >= 14 and clang >= 17,
failing on:
```
../subprojects/mocklibc-1.0/src/netgroup-debug.c:25:3: error: implicit declaration of function ‘print_indent’ [-Wimplicit-function-declaration]
   25 |   print_indent(stream, indent);
      |   ^~~~~~~~~~~~
```

Closes: polkit-org#6
jrybar-rh pushed a commit that referenced this issue Mar 12, 2024
This fixes build error with GCC >= 14 and clang >= 17,
failing on:
```
../subprojects/mocklibc-1.0/src/netgroup-debug.c:25:3: error: implicit declaration of function ‘print_indent’ [-Wimplicit-function-declaration]
   25 |   print_indent(stream, indent);
      |   ^~~~~~~~~~~~
```

Closes: #6
mrc0mmand added a commit to mrc0mmand/polkit that referenced this issue Jun 10, 2024
duk_error() never returns, so the error string gets leaked every time an error
is thrown. Let's avoid this by creating the error object first without throwing
it, freeing the original error string (we don't need it anymore since it gets
sprintf-ed into the error object), and then throwing the error object from top
of the current context stack.

 =================================================================
==1270==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 231 byte(s) in 2 object(s) allocated from:
    #0 0x7f3a489258b7 in malloc (/lib64/libasan.so.8+0xf68b7) (BuildId: 388cbb99455c2e2eaec79bd8db6d9a78eb39f80d)
    #1 0x7f3a47b27487 in __vasprintf_internal (/lib64/libc.so.6+0x8a487) (BuildId: 4a92fcedbba6d6d2629ce066a2970017faa9995e)
    #2 0x7f3a484b06a2 in g_vasprintf (/lib64/libglib-2.0.so.0+0xb16a2) (BuildId: 795136df3faa85587229ddc59d709f81d6f697df)
    #3 0x7f3a48480a92 in g_strdup_vprintf (/lib64/libglib-2.0.so.0+0x81a92) (BuildId: 795136df3faa85587229ddc59d709f81d6f697df)
    polkit-org#4 0x7f3a48480b50 in g_strdup_printf (/lib64/libglib-2.0.so.0+0x81b50) (BuildId: 795136df3faa85587229ddc59d709f81d6f697df)
    polkit-org#5 0x41fcec in js_polkit_spawn ../src/polkitbackend/polkitbackendduktapeauthority.c:1090
    polkit-org#6 0x7f3a483b31b8 in duk__handle_call_raw.lto_priv.0 (/lib64/libduktape.so.207+0x2a1b8) (BuildId: a9f661ee1766489794e9ece7cfd0d6a7fb420ccb)
    polkit-org#7 0x7f3a483962e1 in duk__js_execute_bytecode_inner.lto_priv.0 (/lib64/libduktape.so.207+0xd2e1) (BuildId: a9f661ee1766489794e9ece7cfd0d6a7fb420ccb)
    polkit-org#8 0x7f3a483b33eb in duk_js_execute_bytecode (/lib64/libduktape.so.207+0x2a3eb) (BuildId: a9f661ee1766489794e9ece7cfd0d6a7fb420ccb)
    polkit-org#9 0x7f3a483b319d in duk__handle_call_raw.lto_priv.0 (/lib64/libduktape.so.207+0x2a19d) (BuildId: a9f661ee1766489794e9ece7cfd0d6a7fb420ccb)
    polkit-org#10 0x7f3a48399ab0 in duk__pcall_prop_raw (/lib64/libduktape.so.207+0x10ab0) (BuildId: a9f661ee1766489794e9ece7cfd0d6a7fb420ccb)
    polkit-org#11 0x7f3a483b23cc in duk_handle_safe_call.lto_priv.0 (/lib64/libduktape.so.207+0x293cc) (BuildId: a9f661ee1766489794e9ece7cfd0d6a7fb420ccb)
    polkit-org#12 0x7f3a483972e8 in duk_pcall_prop (/lib64/libduktape.so.207+0xe2e8) (BuildId: a9f661ee1766489794e9ece7cfd0d6a7fb420ccb)
    polkit-org#13 0x41d048 in runaway_killer_thread_call_js ../src/polkitbackend/polkitbackendduktapeauthority.c:682
    polkit-org#14 0x7f3a4888cb45 in asan_thread_start(void*) (/lib64/libasan.so.8+0x5db45) (BuildId: 388cbb99455c2e2eaec79bd8db6d9a78eb39f80d)

Direct leak of 128 byte(s) in 1 object(s) allocated from:
    #0 0x7f3a489247b8 in realloc.part.0 (/lib64/libasan.so.8+0xf57b8) (BuildId: 388cbb99455c2e2eaec79bd8db6d9a78eb39f80d)
    #1 0x7f3a4846304a in g_realloc (/lib64/libglib-2.0.so.0+0x6404a) (BuildId: 795136df3faa85587229ddc59d709f81d6f697df)
    #2 0x7f3a48481b19 in g_string_expand (/lib64/libglib-2.0.so.0+0x82b19) (BuildId: 795136df3faa85587229ddc59d709f81d6f697df)
    #3 0x7f3a48481b90 in g_string_sized_new (/lib64/libglib-2.0.so.0+0x82b90) (BuildId: 795136df3faa85587229ddc59d709f81d6f697df)
    polkit-org#4 0x41fb0f in js_polkit_spawn ../src/polkitbackend/polkitbackendduktapeauthority.c:1099
    polkit-org#5 0x7f3a483b31b8 in duk__handle_call_raw.lto_priv.0 (/lib64/libduktape.so.207+0x2a1b8) (BuildId: a9f661ee1766489794e9ece7cfd0d6a7fb420ccb)
    polkit-org#6 0x7f3a483962e1 in duk__js_execute_bytecode_inner.lto_priv.0 (/lib64/libduktape.so.207+0xd2e1) (BuildId: a9f661ee1766489794e9ece7cfd0d6a7fb420ccb)
    polkit-org#7 0x7f3a483b33eb in duk_js_execute_bytecode (/lib64/libduktape.so.207+0x2a3eb) (BuildId: a9f661ee1766489794e9ece7cfd0d6a7fb420ccb)
    polkit-org#8 0x7f3a483b319d in duk__handle_call_raw.lto_priv.0 (/lib64/libduktape.so.207+0x2a19d) (BuildId: a9f661ee1766489794e9ece7cfd0d6a7fb420ccb)
    polkit-org#9 0x7f3a48399ab0 in duk__pcall_prop_raw (/lib64/libduktape.so.207+0x10ab0) (BuildId: a9f661ee1766489794e9ece7cfd0d6a7fb420ccb)
    polkit-org#10 0x7f3a483b23cc in duk_handle_safe_call.lto_priv.0 (/lib64/libduktape.so.207+0x293cc) (BuildId: a9f661ee1766489794e9ece7cfd0d6a7fb420ccb)
    polkit-org#11 0x7f3a483972e8 in duk_pcall_prop (/lib64/libduktape.so.207+0xe2e8) (BuildId: a9f661ee1766489794e9ece7cfd0d6a7fb420ccb)
    polkit-org#12 0x41d048 in runaway_killer_thread_call_js ../src/polkitbackend/polkitbackendduktapeauthority.c:682
    polkit-org#13 0x7f3a4888cb45 in asan_thread_start(void*) (/lib64/libasan.so.8+0x5db45) (BuildId: 388cbb99455c2e2eaec79bd8db6d9a78eb39f80d)

SUMMARY: AddressSanitizer: 359 byte(s) leaked in 3 allocation(s).
mrc0mmand added a commit to mrc0mmand/polkit that referenced this issue Jun 26, 2024
duk_error() never returns, so the error string gets leaked every time an error
is thrown. Let's avoid this by creating the error object first without throwing
it, freeing the original error string (we don't need it anymore since it gets
sprintf-ed into the error object), and then throwing the error object from top
of the current context stack.

 =================================================================
==1270==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 231 byte(s) in 2 object(s) allocated from:
    #0 0x7f3a489258b7 in malloc (/lib64/libasan.so.8+0xf68b7) (BuildId: 388cbb99455c2e2eaec79bd8db6d9a78eb39f80d)
    #1 0x7f3a47b27487 in __vasprintf_internal (/lib64/libc.so.6+0x8a487) (BuildId: 4a92fcedbba6d6d2629ce066a2970017faa9995e)
    #2 0x7f3a484b06a2 in g_vasprintf (/lib64/libglib-2.0.so.0+0xb16a2) (BuildId: 795136df3faa85587229ddc59d709f81d6f697df)
    #3 0x7f3a48480a92 in g_strdup_vprintf (/lib64/libglib-2.0.so.0+0x81a92) (BuildId: 795136df3faa85587229ddc59d709f81d6f697df)
    polkit-org#4 0x7f3a48480b50 in g_strdup_printf (/lib64/libglib-2.0.so.0+0x81b50) (BuildId: 795136df3faa85587229ddc59d709f81d6f697df)
    polkit-org#5 0x41fcec in js_polkit_spawn ../src/polkitbackend/polkitbackendduktapeauthority.c:1090
    polkit-org#6 0x7f3a483b31b8 in duk__handle_call_raw.lto_priv.0 (/lib64/libduktape.so.207+0x2a1b8) (BuildId: a9f661ee1766489794e9ece7cfd0d6a7fb420ccb)
    polkit-org#7 0x7f3a483962e1 in duk__js_execute_bytecode_inner.lto_priv.0 (/lib64/libduktape.so.207+0xd2e1) (BuildId: a9f661ee1766489794e9ece7cfd0d6a7fb420ccb)
    polkit-org#8 0x7f3a483b33eb in duk_js_execute_bytecode (/lib64/libduktape.so.207+0x2a3eb) (BuildId: a9f661ee1766489794e9ece7cfd0d6a7fb420ccb)
    polkit-org#9 0x7f3a483b319d in duk__handle_call_raw.lto_priv.0 (/lib64/libduktape.so.207+0x2a19d) (BuildId: a9f661ee1766489794e9ece7cfd0d6a7fb420ccb)
    polkit-org#10 0x7f3a48399ab0 in duk__pcall_prop_raw (/lib64/libduktape.so.207+0x10ab0) (BuildId: a9f661ee1766489794e9ece7cfd0d6a7fb420ccb)
    polkit-org#11 0x7f3a483b23cc in duk_handle_safe_call.lto_priv.0 (/lib64/libduktape.so.207+0x293cc) (BuildId: a9f661ee1766489794e9ece7cfd0d6a7fb420ccb)
    polkit-org#12 0x7f3a483972e8 in duk_pcall_prop (/lib64/libduktape.so.207+0xe2e8) (BuildId: a9f661ee1766489794e9ece7cfd0d6a7fb420ccb)
    polkit-org#13 0x41d048 in runaway_killer_thread_call_js ../src/polkitbackend/polkitbackendduktapeauthority.c:682
    polkit-org#14 0x7f3a4888cb45 in asan_thread_start(void*) (/lib64/libasan.so.8+0x5db45) (BuildId: 388cbb99455c2e2eaec79bd8db6d9a78eb39f80d)

Direct leak of 128 byte(s) in 1 object(s) allocated from:
    #0 0x7f3a489247b8 in realloc.part.0 (/lib64/libasan.so.8+0xf57b8) (BuildId: 388cbb99455c2e2eaec79bd8db6d9a78eb39f80d)
    #1 0x7f3a4846304a in g_realloc (/lib64/libglib-2.0.so.0+0x6404a) (BuildId: 795136df3faa85587229ddc59d709f81d6f697df)
    #2 0x7f3a48481b19 in g_string_expand (/lib64/libglib-2.0.so.0+0x82b19) (BuildId: 795136df3faa85587229ddc59d709f81d6f697df)
    #3 0x7f3a48481b90 in g_string_sized_new (/lib64/libglib-2.0.so.0+0x82b90) (BuildId: 795136df3faa85587229ddc59d709f81d6f697df)
    polkit-org#4 0x41fb0f in js_polkit_spawn ../src/polkitbackend/polkitbackendduktapeauthority.c:1099
    polkit-org#5 0x7f3a483b31b8 in duk__handle_call_raw.lto_priv.0 (/lib64/libduktape.so.207+0x2a1b8) (BuildId: a9f661ee1766489794e9ece7cfd0d6a7fb420ccb)
    polkit-org#6 0x7f3a483962e1 in duk__js_execute_bytecode_inner.lto_priv.0 (/lib64/libduktape.so.207+0xd2e1) (BuildId: a9f661ee1766489794e9ece7cfd0d6a7fb420ccb)
    polkit-org#7 0x7f3a483b33eb in duk_js_execute_bytecode (/lib64/libduktape.so.207+0x2a3eb) (BuildId: a9f661ee1766489794e9ece7cfd0d6a7fb420ccb)
    polkit-org#8 0x7f3a483b319d in duk__handle_call_raw.lto_priv.0 (/lib64/libduktape.so.207+0x2a19d) (BuildId: a9f661ee1766489794e9ece7cfd0d6a7fb420ccb)
    polkit-org#9 0x7f3a48399ab0 in duk__pcall_prop_raw (/lib64/libduktape.so.207+0x10ab0) (BuildId: a9f661ee1766489794e9ece7cfd0d6a7fb420ccb)
    polkit-org#10 0x7f3a483b23cc in duk_handle_safe_call.lto_priv.0 (/lib64/libduktape.so.207+0x293cc) (BuildId: a9f661ee1766489794e9ece7cfd0d6a7fb420ccb)
    polkit-org#11 0x7f3a483972e8 in duk_pcall_prop (/lib64/libduktape.so.207+0xe2e8) (BuildId: a9f661ee1766489794e9ece7cfd0d6a7fb420ccb)
    polkit-org#12 0x41d048 in runaway_killer_thread_call_js ../src/polkitbackend/polkitbackendduktapeauthority.c:682
    polkit-org#13 0x7f3a4888cb45 in asan_thread_start(void*) (/lib64/libasan.so.8+0x5db45) (BuildId: 388cbb99455c2e2eaec79bd8db6d9a78eb39f80d)

SUMMARY: AddressSanitizer: 359 byte(s) leaked in 3 allocation(s).
jrybar-rh pushed a commit that referenced this issue Jun 26, 2024
* test: drop mocklibc

Let's get rid of mocklibc and replace it with a simple combination of
mount & user namespaces + bind mount to replace the host's /etc with our
own version.

This means we don't $LD_PRELOAD the mocklibc DSO, but instead run each
unit test through a very simple python wrapper that sets up a temporary
user & mount namespace through the unshare() syscall,  gains "fake" root
using uid_map and gid_map, overmounts /etc in this new namespace (with
our own custom test files), and then executes the test binary itself.
Check user_namespaces(7) for more information about the namespace
shenanigans.

* Replace duk_error() with duk_push_error_object() + duk_throw()

duk_error() never returns, so the error string gets leaked every time an error
is thrown. Let's avoid this by creating the error object first without throwing
it, freeing the original error string (we don't need it anymore since it gets
sprintf-ed into the error object), and then throwing the error object from top
of the current context stack.

 =================================================================
==1270==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 231 byte(s) in 2 object(s) allocated from:
    #0 0x7f3a489258b7 in malloc (/lib64/libasan.so.8+0xf68b7) (BuildId: 388cbb99455c2e2eaec79bd8db6d9a78eb39f80d)
    #1 0x7f3a47b27487 in __vasprintf_internal (/lib64/libc.so.6+0x8a487) (BuildId: 4a92fcedbba6d6d2629ce066a2970017faa9995e)
    #2 0x7f3a484b06a2 in g_vasprintf (/lib64/libglib-2.0.so.0+0xb16a2) (BuildId: 795136df3faa85587229ddc59d709f81d6f697df)
    #3 0x7f3a48480a92 in g_strdup_vprintf (/lib64/libglib-2.0.so.0+0x81a92) (BuildId: 795136df3faa85587229ddc59d709f81d6f697df)
    #4 0x7f3a48480b50 in g_strdup_printf (/lib64/libglib-2.0.so.0+0x81b50) (BuildId: 795136df3faa85587229ddc59d709f81d6f697df)
    #5 0x41fcec in js_polkit_spawn ../src/polkitbackend/polkitbackendduktapeauthority.c:1090
    #6 0x7f3a483b31b8 in duk__handle_call_raw.lto_priv.0 (/lib64/libduktape.so.207+0x2a1b8) (BuildId: a9f661ee1766489794e9ece7cfd0d6a7fb420ccb)
    #7 0x7f3a483962e1 in duk__js_execute_bytecode_inner.lto_priv.0 (/lib64/libduktape.so.207+0xd2e1) (BuildId: a9f661ee1766489794e9ece7cfd0d6a7fb420ccb)
    #8 0x7f3a483b33eb in duk_js_execute_bytecode (/lib64/libduktape.so.207+0x2a3eb) (BuildId: a9f661ee1766489794e9ece7cfd0d6a7fb420ccb)
    #9 0x7f3a483b319d in duk__handle_call_raw.lto_priv.0 (/lib64/libduktape.so.207+0x2a19d) (BuildId: a9f661ee1766489794e9ece7cfd0d6a7fb420ccb)
    #10 0x7f3a48399ab0 in duk__pcall_prop_raw (/lib64/libduktape.so.207+0x10ab0) (BuildId: a9f661ee1766489794e9ece7cfd0d6a7fb420ccb)
    #11 0x7f3a483b23cc in duk_handle_safe_call.lto_priv.0 (/lib64/libduktape.so.207+0x293cc) (BuildId: a9f661ee1766489794e9ece7cfd0d6a7fb420ccb)
    #12 0x7f3a483972e8 in duk_pcall_prop (/lib64/libduktape.so.207+0xe2e8) (BuildId: a9f661ee1766489794e9ece7cfd0d6a7fb420ccb)
    #13 0x41d048 in runaway_killer_thread_call_js ../src/polkitbackend/polkitbackendduktapeauthority.c:682
    #14 0x7f3a4888cb45 in asan_thread_start(void*) (/lib64/libasan.so.8+0x5db45) (BuildId: 388cbb99455c2e2eaec79bd8db6d9a78eb39f80d)

Direct leak of 128 byte(s) in 1 object(s) allocated from:
    #0 0x7f3a489247b8 in realloc.part.0 (/lib64/libasan.so.8+0xf57b8) (BuildId: 388cbb99455c2e2eaec79bd8db6d9a78eb39f80d)
    #1 0x7f3a4846304a in g_realloc (/lib64/libglib-2.0.so.0+0x6404a) (BuildId: 795136df3faa85587229ddc59d709f81d6f697df)
    #2 0x7f3a48481b19 in g_string_expand (/lib64/libglib-2.0.so.0+0x82b19) (BuildId: 795136df3faa85587229ddc59d709f81d6f697df)
    #3 0x7f3a48481b90 in g_string_sized_new (/lib64/libglib-2.0.so.0+0x82b90) (BuildId: 795136df3faa85587229ddc59d709f81d6f697df)
    #4 0x41fb0f in js_polkit_spawn ../src/polkitbackend/polkitbackendduktapeauthority.c:1099
    #5 0x7f3a483b31b8 in duk__handle_call_raw.lto_priv.0 (/lib64/libduktape.so.207+0x2a1b8) (BuildId: a9f661ee1766489794e9ece7cfd0d6a7fb420ccb)
    #6 0x7f3a483962e1 in duk__js_execute_bytecode_inner.lto_priv.0 (/lib64/libduktape.so.207+0xd2e1) (BuildId: a9f661ee1766489794e9ece7cfd0d6a7fb420ccb)
    #7 0x7f3a483b33eb in duk_js_execute_bytecode (/lib64/libduktape.so.207+0x2a3eb) (BuildId: a9f661ee1766489794e9ece7cfd0d6a7fb420ccb)
    #8 0x7f3a483b319d in duk__handle_call_raw.lto_priv.0 (/lib64/libduktape.so.207+0x2a19d) (BuildId: a9f661ee1766489794e9ece7cfd0d6a7fb420ccb)
    #9 0x7f3a48399ab0 in duk__pcall_prop_raw (/lib64/libduktape.so.207+0x10ab0) (BuildId: a9f661ee1766489794e9ece7cfd0d6a7fb420ccb)
    #10 0x7f3a483b23cc in duk_handle_safe_call.lto_priv.0 (/lib64/libduktape.so.207+0x293cc) (BuildId: a9f661ee1766489794e9ece7cfd0d6a7fb420ccb)
    #11 0x7f3a483972e8 in duk_pcall_prop (/lib64/libduktape.so.207+0xe2e8) (BuildId: a9f661ee1766489794e9ece7cfd0d6a7fb420ccb)
    #12 0x41d048 in runaway_killer_thread_call_js ../src/polkitbackend/polkitbackendduktapeauthority.c:682
    #13 0x7f3a4888cb45 in asan_thread_start(void*) (/lib64/libasan.so.8+0x5db45) (BuildId: 388cbb99455c2e2eaec79bd8db6d9a78eb39f80d)

SUMMARY: AddressSanitizer: 359 byte(s) leaked in 3 allocation(s).

* packit: run unit tests during package build
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant