Skip to content

Conversation

@Cropi
Copy link
Member

@Cropi Cropi commented Aug 19, 2022

  1. If polkit_authority_get_sync() fails, then it will return null, so there is no need to free it with g_object_unref().
  2. The same goes for polkit_authority_check_authorization_sync(). The documentation says the following: "A PolkitAuthorizationResult is returned or NULL if error is set. Free with g_object_unref()."

I came across this issue when SElinux did not allow usbguard-dbus to perform the mentioned actions. Thus, usbguard tried to free memory, which was not even allocated.

[1] https://www.freedesktop.org/software/polkit/docs/latest/PolkitAuthority.html

Copy link
Contributor

@hartwork hartwork left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @Cropi ,

for review of this pull request I asked myself two questions:

  • Can function polkit_authority_get_sync return NULL?
    I found the answer in file polkit-v.121/src/polkit/polkitauthority.c: Yes, it can.

  • Can function g_object_unref be called with NULL, safely?
    After some digging, the answer is: No, it cannot.

With those two answers I agree that this pull request is moving the code into the right direction and fixes a real problem 👍 . I would suggest to also drop the second || error from ! authority || error for both consistency and readability, and then I'd consider it "perfect". What do you think?

Best, Sebastian

@hartwork
Copy link
Contributor

hartwork commented Aug 19, 2022

@Cropi PS: For the CI failure with Ubuntu 21.10, I believe the main point was to cover the most recent Ubuntu, more recent than GitHub CI's ubuntu-latest, so maybe we should migrate to Ubuntu 22.04 there, ideally in a dedicated pull request. I have prepared pull request #552 for that now and we could rebase #551 on top of that, after #552 is merged, if you like. What do you think?

@Cropi
Copy link
Member Author

Cropi commented Aug 22, 2022

Hi @Cropi ,

for review of this pull request I asked myself two questions:

* Can function `polkit_authority_get_sync` return `NULL`?
  I found the answer in file `polkit-v.121/src/polkit/polkitauthority.c`: Yes, it can.

* Can function `g_object_unref` be called with `NULL`, safely?
  After some digging, the answer is: No, it cannot.

With those two answers I agree that this pull request is moving the code into the right direction and fixes a real problem +1 . I would suggest to also drop the second || error from ! authority || error for both consistency and readability, and then I'd consider it "perfect". What do you think?

Best, Sebastian

Thanks for the review. I definitely agree that we should change the authority part as well to ensure better consistency.

@Cropi Cropi merged commit 20deda7 into USBGuard:master Aug 22, 2022
@Cropi Cropi deleted the correct-unref branch August 22, 2022 08:23
@hartwork
Copy link
Contributor

hartwork commented Aug 22, 2022

@Cropi with PRs #548, #551, #552 all merged now — how do you feel about cutting a release 1.1.2 off master?

@Cropi
Copy link
Member Author

Cropi commented Aug 23, 2022

@Cropi with PRs #548, #551, #552 all merged now — how do you feel about cutting a release 1.1.2 off master?

I am not against it but usually @radosroka is the one who creates the releases.

@hartwork
Copy link
Contributor

hartwork commented Sep 2, 2022

@radosroka any chance or objections?

@radosroka
Copy link
Member

@radosroka any chance or objections?

I can create release later today.

@hartwork
Copy link
Contributor

hartwork commented Sep 2, 2022

@radosroka cool! Thank you!

@radosroka
Copy link
Member

@radosroka cool! Thank you!

Release is out there:

https://github.com/USBGuard/usbguard/releases/tag/usbguard-1.1.2

@hartwork
Copy link
Contributor

hartwork commented Sep 2, 2022

@radosroka thank you! Bumped to 1.1.2 in Gentoo as well now.

@Cropi Cropi self-assigned this Dec 13, 2022
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.

3 participants