This commit is contained in:
Peter Robinson 2021-07-08 22:51:05 +01:00
parent 19b82e32f5
commit 22fac2ae2f
3 changed files with 6 additions and 90 deletions

View File

@ -1,84 +0,0 @@
From 382646b490c1c336dd32f9186293616ceb4d808b Mon Sep 17 00:00:00 2001
From: Benjamin Berg <bberg@redhat.com>
Date: Mon, 3 May 2021 14:45:00 +0200
Subject: [PATCH 1/2] rfkill: Fix reading from rfkill socket
The kernel will always send exactly one event, but the size of the
passed struct will depend on the length of the submitted read() and the
kernel version. i.e. the interface can be extended and we need to expect
for a read to be longer than expected if we ask for it.
Fix this by only requesting the needed length and explicitly check the
length against the V1 version of the structure to make the code a bit
more future proof in case the internal copy of the struct is updated to
contain new fields.
---
src/rfkill.c | 24 +++++++++++-------------
1 file changed, 11 insertions(+), 13 deletions(-)
diff --git a/src/rfkill.c b/src/rfkill.c
index ec9fcdfdd..2099c5ac5 100644
--- a/src/rfkill.c
+++ b/src/rfkill.c
@@ -53,12 +53,12 @@ struct rfkill_event {
uint8_t soft;
uint8_t hard;
};
+#define RFKILL_EVENT_SIZE_V1 8
static gboolean rfkill_event(GIOChannel *chan,
GIOCondition cond, gpointer data)
{
- unsigned char buf[32];
- struct rfkill_event *event = (void *) buf;
+ struct rfkill_event event = { 0 };
struct btd_adapter *adapter;
char sysname[PATH_MAX];
ssize_t len;
@@ -69,34 +69,32 @@ static gboolean rfkill_event(GIOChannel *chan,
fd = g_io_channel_unix_get_fd(chan);
- memset(buf, 0, sizeof(buf));
-
- len = read(fd, buf, sizeof(buf));
+ len = read(fd, &event, sizeof(event));
if (len < 0) {
if (errno == EAGAIN)
return TRUE;
return FALSE;
}
- if (len != sizeof(struct rfkill_event))
+ if (len < RFKILL_EVENT_SIZE_V1)
return TRUE;
DBG("RFKILL event idx %u type %u op %u soft %u hard %u",
- event->idx, event->type, event->op,
- event->soft, event->hard);
+ event.idx, event.type, event.op,
+ event.soft, event.hard);
- if (event->soft || event->hard)
+ if (event.soft || event.hard)
return TRUE;
- if (event->op != RFKILL_OP_CHANGE)
+ if (event.op != RFKILL_OP_CHANGE)
return TRUE;
- if (event->type != RFKILL_TYPE_BLUETOOTH &&
- event->type != RFKILL_TYPE_ALL)
+ if (event.type != RFKILL_TYPE_BLUETOOTH &&
+ event.type != RFKILL_TYPE_ALL)
return TRUE;
snprintf(sysname, sizeof(sysname) - 1,
- "/sys/class/rfkill/rfkill%u/name", event->idx);
+ "/sys/class/rfkill/rfkill%u/name", event.idx);
fd = open(sysname, O_RDONLY);
if (fd < 0)
--
2.31.1

View File

@ -5,7 +5,7 @@
%endif %endif
Name: bluez Name: bluez
Version: 5.59 Version: 5.60
Release: 1%{?dist} Release: 1%{?dist}
Summary: Bluetooth utilities Summary: Bluetooth utilities
License: GPLv2+ License: GPLv2+
@ -23,9 +23,6 @@ Patch12: 0003-systemd-Add-more-filesystem-lockdown.patch
Patch13: 0004-systemd-More-lockdown.patch Patch13: 0004-systemd-More-lockdown.patch
Patch14: 0005-media-rename-local-function-conflicting-with-pause-2.patch Patch14: 0005-media-rename-local-function-conflicting-with-pause-2.patch
# Fix rfkill reading from newer kernels
Patch15: 0001-rfkill-Fix-reading-from-rfkill-socket.patch
# Fix FTBFS with newer glib versions # Fix FTBFS with newer glib versions
Patch16: 0002-Use-g_memdup2-everywhere.patch Patch16: 0002-Use-g_memdup2-everywhere.patch
@ -153,7 +150,7 @@ Object Exchange daemon for sharing files, contacts etc over bluetooth
%build %build
autoreconf -vif autoreconf -vif
%configure --enable-tools --enable-library \ %configure --enable-tools --enable-library --disable-optimization \
%if %{with deprecated} %if %{with deprecated}
--enable-deprecated \ --enable-deprecated \
%endif %endif
@ -325,6 +322,9 @@ install emulator/btvirt ${RPM_BUILD_ROOT}/%{_libexecdir}/bluetooth/
%{_userunitdir}/obex.service %{_userunitdir}/obex.service
%changelog %changelog
* Thu Jul 08 2021 Peter Robinson <pbrobinson@fedoraproject.org> - 5.60-1
- Update to 5.60
* Tue Jun 15 2021 Peter Robinson <pbrobinson@fedoraproject.org> - 5.59-1 * Tue Jun 15 2021 Peter Robinson <pbrobinson@fedoraproject.org> - 5.59-1
- Update to 5.59 - Update to 5.59

View File

@ -1 +1 @@
SHA512 (bluez-5.59.tar.xz) = 506ce28459a82614e5f6c55235b84e5780a9bfa821904fd40ee2928a503978248368069c57a283db9dd81f48d78f45e00d95a7c52d1538d3f5c858a29424304f SHA512 (bluez-5.60.tar.xz) = 069e054360b4ab72f1daa033572f0fd822fb0f47e52069f4f3dcdfecfa312b9a5366cc04967e639aef39b980c0e1007389f1ee757e7c3bae43a5e66f8ed21a6b