USBGuard / usbguard

USBGuard is a software framework for implementing USB device authorization policies (what kind of USB devices are authorized) as well as method of use policies (how a USB device may interact with the system)
https://usbguard.github.io/
GNU General Public License v2.0
1.1k stars 133 forks source link

Fix compile with GCC 13 #582

Closed yselkowitz closed 1 year ago

yselkowitz commented 1 year ago

This is needed for https://gcc.gnu.org/gcc-13/porting_to.html

Cropi commented 1 year ago

We will need to extend the CI with gcc-13, but after investigation it seems like that it's not yet available on ubuntu-22.04. This does not block us from merging the PR. Thanks.

rfrohl commented 1 year ago

We ran into the same issue with openSUSE, and I can confirm that something like this fixes the issue with gcc13. But a small note for the patch:

The include should be moved from Base64.cpp to Base64.hpp, meaning this part is missing from the patch:

diff --git a/src/Library/Base64.cpp b/src/Library/Base64.cpp                                                                                                                                                                                   
index ddb28dc..0246a13 100644                                                                                                                                                                                                                  
--- a/src/Library/Base64.cpp                                                                                                                                                                                                                   
+++ b/src/Library/Base64.cpp                                                                                                                                                                                                                   
@@ -22,7 +22,6 @@                                                                                                                                                                                                                              

 #include "Base64.hpp"                                                                                                                                                                                                                         
 #include <stdexcept>                                                                                                                                                                                                                          
-#include <cstdint>                                                                                                                                                                                                                            

 namespace usbguard                                                                                                                                                                                                                            
 {
hartwork commented 1 year ago

@rfrohl the addition is proposed for Base64.hpp which is included from Base64.cpp. So I believe the PR already does exactly what you want. Could you re-check and help me understand what I may be missing?

rfrohl commented 1 year ago

I just wanted to highlight that the include should be moved instead of just adding it to Base64.hpp.

I only later saw #583, which is the exact change that I think would be the cleanest and it includes the removal of the include in Base64.cpp. But both of them fix the issue.

hartwork commented 1 year ago

@rfrohl now I understand — thank for the clarification! :+1:

@Cropi can we merge more complete #583 and close #582 here as superseded? I see use of uint8_t in Base64.hpp so even without GCC 13 around for testing, the pull request seems justified.

PS: @rfrohl what distro are you on, which way do you access GCC 13? I re-check myself just now and I see no GCC 13 at https://hub.docker.com/_/gcc and Gentoo also has GCC 13 hard-masked, still. Just curious.

rfrohl commented 1 year ago

PS: @rfrohl what distro are you on, which way do you access GCC 13? I re-check myself just now and I see no GCC 13 at https://hub.docker.com/_/gcc and Gentoo also has GCC 13 hard-masked, still. Just curious.

openSUSE Tumbleweed switched to gcc13 on the 21th of March [0] and we are cleaning up the last smaller problems. I just realized today that usbguard stopped building and was working on a quick resolution (and therefor was looking if someone already reported/fixed the issue upstream to avoid the issue for other maintainers).

[0] https://lists.opensuse.org/archives/list/factory@lists.opensuse.org/thread/HROWLRAA5ZYK2S6IJ4GMSMPFHCSCNFKG/

Cropi commented 1 year ago

Thank you for the PR. I am closing it as it has been fixed in https://github.com/USBGuard/usbguard/pull/586