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

A couple of fixes for issues discovered by GCC analyzer #529

Merged
merged 4 commits into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .packit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ files_to_sync:
upstream_package_name: polkit
# downstream (Fedora) RPM package name
downstream_package_name: polkit
# arguments for OpenScanHub
mrc0mmand marked this conversation as resolved.
Show resolved Hide resolved
#
# Note: 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.
csmock_args: --gcc-add-flag=-flto=auto

jobs:
- job: copr_build
Expand Down
1 change: 1 addition & 0 deletions src/polkit/polkitpermission.c
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,7 @@ changed_check_cb (GObject *source_object,
/* this really should never fail (since we are not passing any
* details) so log to stderr if it happens
*/
g_assert (error != NULL);
g_warning ("Error checking authorization for action id %s: %s",
permission->action_id,
error->message);
Expand Down
1 change: 1 addition & 0 deletions src/polkitagent/polkitagenthelper-pam.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ send_to_helper (const gchar *str1,
size_t len2;

tmp2 = g_strdup(str2);
g_assert (tmp2 != NULL);
len2 = strlen(tmp2);
#ifdef PAH_DEBUG
fprintf (stderr, "polkit-agent-helper-1: writing `%s ' to stdout\n", str1);
Expand Down
15 changes: 5 additions & 10 deletions src/polkitbackend/polkitbackendduktapeauthority.c
Original file line number Diff line number Diff line change
Expand Up @@ -559,8 +559,7 @@ else
static gboolean
push_action_and_details (duk_context *cx,
const gchar *action_id,
PolkitDetails *details,
GError **error)
PolkitDetails *details)
{
gchar **keys;
guint n;
Expand Down Expand Up @@ -926,13 +925,11 @@ polkit_backend_common_js_authority_get_admin_auth_identities (PolkitBackendInter

duk_push_string (cx, "_runAdminRules");

if (!push_action_and_details (cx, action_id, details, &error))
if (!push_action_and_details (cx, action_id, details))
{
polkit_backend_authority_log (POLKIT_BACKEND_AUTHORITY (authority),
LOG_LEVEL_ERROR,
"Error converting action and details to JS object: %s",
error->message);
g_clear_error (&error);
"Error converting action and details to JS object");
goto out;
}

Expand Down Expand Up @@ -1010,13 +1007,11 @@ polkit_backend_common_js_authority_check_authorization_sync (PolkitBackendIntera

duk_push_string (cx, "_runRules");

if (!push_action_and_details (cx, action_id, details, &error))
if (!push_action_and_details (cx, action_id, details))
{
polkit_backend_authority_log (POLKIT_BACKEND_AUTHORITY (authority),
LOG_LEVEL_ERROR,
"Error converting action and details to JS object: %s",
error->message);
g_clear_error (&error);
"Error converting action and details to JS object");
goto out;
}

Expand Down
5 changes: 5 additions & 0 deletions src/programs/pkexec.c
Original file line number Diff line number Diff line change
Expand Up @@ -814,6 +814,11 @@ main (int argc, char *argv[])
polkit_details_insert (details, "command_line", command_line);

cmdline_short = g_strdup(command_line);
if (cmdline_short == NULL)
{
g_printerr ("Failed to allocate memory for shortened command line.\n");
goto out;
}
if (strlen(command_line) > 80)
g_stpcpy(g_stpcpy( cmdline_short + 38, " ... " ),
command_line + strlen(command_line) - 37 );
Expand Down