backport device: Fix client_username memory leak

This commit is contained in:
liyuan 2023-12-21 21:22:14 +08:00
parent fa8167e058
commit b2d66ddaa6
2 changed files with 53 additions and 1 deletions

View File

@ -0,0 +1,47 @@
From 267e6b3238f41b19b61b6502d52769c06df1c8f6 Mon Sep 17 00:00:00 2001
From: Bastien Nocera <hadess@hadess.net>
Date: Thu, 23 Aug 2018 13:44:14 +0200
Subject: [PATCH] device: Fix client_username memory leak
No need to duplicate that string until we pass it out.
From https://bugs.launchpad.net/ubuntu/+source/fprintd/+bug/1745455/comments/7
---
src/device.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/src/device.c b/src/device.c
index e9b89bc..a305c9f 100644
--- a/src/device.c
+++ b/src/device.c
@@ -469,7 +469,6 @@ _fprint_device_check_for_username (FprintDevice *rdev,
char *sender;
unsigned long uid;
struct passwd *user;
- char *client_username;
/* Get details about the current sender, and username/uid */
conn = dbus_g_connection_get_connection (fprintd_dbus_conn);
@@ -490,17 +489,16 @@ _fprint_device_check_for_username (FprintDevice *rdev,
"Failed to get information about user UID %lu", uid);
return NULL;
}
- client_username = g_strdup (user->pw_name);
/* The current user is usually allowed to access their
* own data, this should be followed by PolicyKit checks
* anyway */
- if (username == NULL || *username == '\0' || g_str_equal (username, client_username)) {
+ if (username == NULL || *username == '\0' || g_str_equal (username, user->pw_name)) {
if (ret_sender != NULL)
*ret_sender = sender;
else
g_free (sender);
- return client_username;
+ return g_strdup (user->pw_name);
}
/* If we're not allowed to set a different username,
--
2.33.0

View File

@ -1,11 +1,13 @@
Name: fprintd
Version: 0.8.1
Release: 5
Release: 6
Summary: Support for consumer fingerprint reader devices
License: GPLv2+
Url: http://www.freedesktop.org/wiki/Software/fprint/fprintd
Source0: https://gitlab.freedesktop.org/libfprint/fprintd/uploads/bdd9f91909f535368b7c21f72311704a/%{name}-%{version}.tar.xz
Patch0001: 0001-device-Fix-client_username-memory-leak.patch
BuildRequires: dbus-glib-devel pam-devel libfprint-devel >= 0.1.0 polkit-devel gtk-doc
BuildRequires: intltool autoconf automake libtool perl-podlators pkgconfig(systemd)
@ -81,6 +83,9 @@ fi
%{_mandir}/man1/fprintd.1.gz
%changelog
* Fri Dec 22 2023 liyuanyuan <liyuanyuan@xfusion.com> - 0.8.1-6
- device: Fix client_username memory leak
* Fri Feb 26 2021 lingsheng <lingsheng@huawei.com> - 0.8.1-5
- Disable with-fingerprint when with-fingerprint is enabled