From 06ec6473c2ed1920a1d98d40fe992dea9f60b103 Mon Sep 17 00:00:00 2001
From: Christian Heusel <christian@heusel.eu>
Date: Tue, 11 Mar 2025 21:43:51 +0100
Subject: [PATCH] Adapt for protobuf 30.0 API changes

Fixes https://github.com/USBGuard/usbguard/issues/649

Upstream-Status: Submitted [https://github.com/USBGuard/usbguard/pull/650]

Link: https://protobuf.dev/support/migration/
Signed-off-by: Christian Heusel <christian@heusel.eu>
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
 src/Library/IPCClientPrivate.cpp | 2 +-
 src/Library/IPCClientPrivate.hpp | 2 +-
 src/Library/IPCServerPrivate.cpp | 6 +++---
 src/Library/IPCServerPrivate.hpp | 2 +-
 4 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/Library/IPCClientPrivate.cpp b/src/Library/IPCClientPrivate.cpp
index 6aa5201..452ecd4 100644
--- a/src/Library/IPCClientPrivate.cpp
+++ b/src/Library/IPCClientPrivate.cpp
@@ -225,7 +225,7 @@ namespace usbguard
     std::string payload;
     message.SerializeToString(&payload);
     struct qb_ipc_request_header hdr;
-    hdr.id = QB_IPC_MSG_USER_START + IPC::messageTypeNameToNumber(message.GetTypeName());
+    hdr.id = QB_IPC_MSG_USER_START + IPC::messageTypeNameToNumber(std::string(message.GetTypeName()));
     hdr.size = sizeof hdr + payload.size();
     struct iovec iov[2];
     iov[0].iov_base = &hdr;
diff --git a/src/Library/IPCClientPrivate.hpp b/src/Library/IPCClientPrivate.hpp
index d92a1d4..a33022e 100644
--- a/src/Library/IPCClientPrivate.hpp
+++ b/src/Library/IPCClientPrivate.hpp
@@ -84,7 +84,7 @@ namespace usbguard
     template<class T>
     void registerHandler(MessageHandler::HandlerType method)
     {
-      const uint32_t type_number = IPC::messageTypeNameToNumber(T::default_instance().GetTypeName());
+      const uint32_t type_number = IPC::messageTypeNameToNumber(std::string(T::default_instance().GetTypeName()));
       _handlers.emplace(type_number, MessageHandler::create<T>(*this, method));
     }
 
diff --git a/src/Library/IPCServerPrivate.cpp b/src/Library/IPCServerPrivate.cpp
index 548a726..b976f02 100644
--- a/src/Library/IPCServerPrivate.cpp
+++ b/src/Library/IPCServerPrivate.cpp
@@ -311,7 +311,7 @@ namespace usbguard
     message->SerializeToString(&payload);
     struct qb_ipc_response_header hdr;
     struct iovec iov[2];
-    hdr.id = QB_IPC_MSG_USER_START + IPC::messageTypeNameToNumber(message->GetTypeName());
+    hdr.id = QB_IPC_MSG_USER_START + IPC::messageTypeNameToNumber(std::string(message->GetTypeName()));
     hdr.size = sizeof hdr + payload.size();
     hdr.error = 0;
     iov[0].iov_base = &hdr;
@@ -555,7 +555,7 @@ namespace usbguard
     std::string payload;
     message->SerializeToString(&payload);
     struct qb_ipc_response_header hdr = { };
-    hdr.id = QB_IPC_MSG_USER_START + IPC::messageTypeNameToNumber(message->GetTypeName());
+    hdr.id = QB_IPC_MSG_USER_START + IPC::messageTypeNameToNumber(std::string(message->GetTypeName()));
     hdr.size = sizeof hdr + payload.size();
     hdr.error = 0;
     struct iovec iov[2];
@@ -563,7 +563,7 @@ namespace usbguard
     iov[0].iov_len = sizeof hdr;
     iov[1].iov_base = (void*)payload.data();
     iov[1].iov_len = payload.size();
-    qbIPCBroadcastData(iov, 2, messageTypeNameToAccessControlSection(message->GetTypeName()));
+    qbIPCBroadcastData(iov, 2, messageTypeNameToAccessControlSection(std::string(message->GetTypeName())));
     iov[0].iov_base = nullptr;
     iov[1].iov_base = nullptr;
   }
diff --git a/src/Library/IPCServerPrivate.hpp b/src/Library/IPCServerPrivate.hpp
index 25f9ac3..3b3dcc5 100644
--- a/src/Library/IPCServerPrivate.hpp
+++ b/src/Library/IPCServerPrivate.hpp
@@ -134,7 +134,7 @@ namespace usbguard
     void registerHandler(MessageHandler::HandlerType method, IPCServer::AccessControl::Section section,
       IPCServer::AccessControl::Privilege privilege)
     {
-      const uint32_t type_number = IPC::messageTypeNameToNumber(T::default_instance().GetTypeName());
+      const uint32_t type_number = IPC::messageTypeNameToNumber(std::string(T::default_instance().GetTypeName()));
       _handlers.emplace(type_number, MessageHandler::create<T>(*this, method, section, privilege));
     }
 
