Skip to content
Snippets Groups Projects
  1. Jan 18, 2025
  2. Jan 17, 2025
  3. Jan 13, 2025
  4. Dec 20, 2024
  5. Dec 19, 2024
  6. Dec 03, 2024
  7. Nov 28, 2024
    • Frantisek Sumsal's avatar
      packit: build Packit with LTO in OpenScanHub · 252b7f39
      Frantisek Sumsal authored
      GCC analyzer in some cases depends on information provided by LTO to
      generate accurate results, but the LTO support in GCC analyzer is still
      experimental, so it's not enabled by default. In Polkit, however, this
      seems to work pretty well, so let's tell OSH to build our code with LTO
      when running GCC analyzer.
      252b7f39
    • Frantisek Sumsal's avatar
      polkitpermission: add a paranoia check for the error object · ff243db4
      Frantisek Sumsal authored
      The error object in this case should always be allocated if
      polkit_authority_check_authorization_finish() returns NULL, so let's
      convey this message to static analyzers as well.
      
      Another potential "solution" for this could be checking the error object
      instead of the result one when returning from
      polkit_authority_check_authorization_finish() (like it's done in the
      respective example - src/examples/cancel.c), but we already have a
      precedent of using g_assert() on the error object for this in our
      codebase.
      
      This should address following warning from GCC analyzer:
      
      [75/89] Linking target src/polkit/libpolkit-gobject-1.so.0.0.0
      ../src/polkit/polkitpermission.c: In function ‘changed_check_cb’:
      ../src/polkit/polkitpermission.c:485:7: warning: dereference of NULL ‘error’ [CWE-476] [-Wanalyzer-null-dereference]
        485 |       g_warning ("Error checking authorization for action id %s: %s",
            |       ^
      ff243db4
    • Frantisek Sumsal's avatar
      backendduktape: avoid dereferencing an always-NULL error object · b8cdbd01
      Frantisek Sumsal authored
      push_action_and_details() never used the "error" argument internally, so
      it always remained set to NULL, which would lead to nasty surprises in
      the error paths.
      
      Found by GCC analyzer:
      
      [84/84] Linking target src/polkitbackend/polkitd
      ../src/polkitbackend/polkitbackendduktapeauthority.c: In function ‘polkit_backend_common_js_authority_check_authorization_sync’:
      ../src/polkitbackend/polkitbackendduktapeauthority.c:1015:7: warning: dereference of NULL ‘error’ [CWE-476] [-Wanalyzer-null-dereference]
       1015 |       polkit_backend_authority_log (POLKIT_BACKEND_AUTHORITY (authority),
      b8cdbd01
    • Frantisek Sumsal's avatar
      Avoid passing NULL to strlen() · 1f396846
      Frantisek Sumsal authored
      As that's a way to a certain segmentation fault.
      
      Discovered by GCC analyzer:
      
      [74/84] Linking target src/polkitagent/polkit-agent-helper-1
      ../src/polkitagent/polkitagenthelper-pam.c: In function ‘send_to_helper’:
      ../src/polkitagent/polkitagenthelper-pam.c:46:10: warning: use of NULL where non-null expected [CWE-476] [-Wanalyzer-null-argument]
         46 |   len2 = strlen(tmp2);
            |          ^
      
      [83/84] Linking target src/programs/pkexec
      ../src/programs/pkexec.c: In function ‘main’:
      ../src/programs/pkexec.c:817:7: warning: use of NULL ‘command_line’ where non-null expected [CWE-476] [-Wanalyzer-null-argument]
        817 |   if (strlen(command_line) > 80)
            |       ^
      1f396846
  8. Nov 14, 2024
  9. Nov 07, 2024
  10. Nov 06, 2024
    • Frantisek Sumsal's avatar
      ci: drop outdated TODO items · fdf9172b
      Frantisek Sumsal authored
      These were fixed by dropping mocklibc.
      fdf9172b
    • Frantisek Sumsal's avatar
      ci: build with -Werror · f5c52132
      Frantisek Sumsal authored
      Suppress the outstanding -Wdeprecated-declarations warnings for now, so
      we don't miss real issues in the future.
      f5c52132
    • Frantisek Sumsal's avatar
      Explicitly discard unused results where necessary · 92c5e68d
      Frantisek Sumsal authored
      setre*id() functions are declared with `warn_unused_result` which makes
      them emit a warning when their result is unused. This warning can be
      suppressed by using (void) cast in clang, so do this where appropriate.
      As gcc doesn't support this, disable the warning completely when gcc is
      used.
      
      See: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66425
      92c5e68d
    • Frantisek Sumsal's avatar
      Use GNU C's "format" function attribute where appropriate · f4f9a89e
      Frantisek Sumsal authored
      Which allows correct type-checking during compilation and avoids errors
      when building with clang + -Werror:
      
      [58/71] Compiling C object src/programs/pkexec.p/pkexec.c.o
      FAILED: src/programs/pkexec.p/pkexec.c.o
      clang -Isrc/programs/pkexec.p -Isrc/programs -I../src/programs -I. -I.. -Isrc/polkitagent -I../src/polkitagent -Isrc -I../src -Isrc/polkit -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/sysprof-6 -I/usr/include/gio-unix-2.0 -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Werror -std=c99 -O2 -g -D_GNU_SOURCE -include config.h -Waggregate-return -Wdeclaration-after-statement -Wformat=2 -Wimplicit-function-declaration -Winit-self -Wmissing-declarations -Wmissing-include-dirs -Wmissing-prototypes -Wstrict-prototypes -Wno-format-y2k -Wno-declaration-after-statement -Wno-deprecated-declarations -pthread -DWITH_GZFILEOP -MD -MQ src/programs/pkexec.p/pkexec.c.o -MF src/programs/pkexec.p/pkexec.c.o.d -o src/programs/pkexec.p/pkexec.c.o -c ../src/programs/pkexec.c
      ../src/programs/pkexec.c:109:25: error: format string is not a string literal [-Werror,-Wformat-nonliteral]
        109 |   s = g_strdup_vprintf (format, var_args);
            |                         ^~~~~~
      1 error generated.
      [59/71] Compiling C object src/polkitbackend/libpolkit-backend-1.a.p/polkitbackendauthority.c.o
      FAILED: src/polkitbackend/libpolkit-backend-1.a.p/polkitbackendauthority.c.o
      clang -Isrc/polkitbackend/libpolkit-backend-1.a.p -Isrc/polkitbackend -I../src/polkitbackend -I. -I.. -Isrc -I../src -Isrc/polkit -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/sysprof-6 -I/usr/include/gio-unix-2.0 -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Werror -std=c99 -O2 -g -D_GNU_SOURCE -include config.h -Waggregate-return -Wdeclaration-after-statement -Wformat=2 -Wimplicit-function-declaration -Winit-self -Wmissing-declarations -Wmissing-include-dirs -Wmissing-prototypes -Wstrict-prototypes -Wno-format-y2k -Wno-declaration-after-statement -Wno-deprecated-declarations -fPIC -pthread -DWITH_GZFILEOP -D_POLKIT_COMPILATION -D_POLKIT_BACKEND_COMPILATION '-DPACKAGE_DATA_DIR="/usr/share"' '-DPACKAGE_SYSCONF_DIR="/etc"' -MD -MQ src/polkitbackend/libpolkit-backend-1.a.p/polkitbackendauthority.c.o -MF src/polkitbackend/libpolkit-backend-1.a.p/polkitbackendauthority.c.o.d -o src/polkitbackend/libpolkit-backend-1.a.p/polkitbackendauthority.c.o -c ../src/polkitbackend/polkitbackendauthority.c
      ../src/polkitbackend/polkitbackendauthority.c:1721:31: error: format string is not a string literal [-Werror,-Wformat-nonliteral]
       1721 |   message = g_strdup_vprintf (format, var_args);
            |                               ^~~~~~
      1 error generated.
      f4f9a89e
Loading