File fix-upstream-userdb-constpointer.patch of Package dbus-1.25333

commit 4ed1b3204d4e6d48d30b33e76a84c8ad57961ffd
Author: Simon McVittie <smcv@collabora.com>
Date:   Tue Jun 30 19:13:17 2020 +0100

    userdb: Make lookups return a const pointer
    
    This makes it more obvious that the returned pointer points to a
    struct owned by the userdb, which must not be freed or have its
    contents modified, and is only valid to dereference until the next
    modification to the userdb's underlying hash tables (which in practice
    means until the lock is released, because after that we have no
    guarantees about what might be going on in another thread).
    
    Signed-off-by: Simon McVittie <smcv@collabora.com>
    (cherry picked from commit 6ee66ff7bcc91803111d950512f02651e664f74f)

Index: dbus-1.8.22/dbus/dbus-userdb-util.c
===================================================================
--- dbus-1.8.22.orig/dbus/dbus-userdb-util.c
+++ dbus-1.8.22/dbus/dbus-userdb-util.c
@@ -240,9 +240,9 @@ _dbus_get_user_id_and_primary_group (con
  * @param gid the group ID or #DBUS_GID_UNSET
  * @param groupname group name or #NULL 
  * @param error error to fill in
- * @returns the entry in the database
+ * @returns the entry in the database (borrowed, do not free)
  */
-DBusGroupInfo*
+const DBusGroupInfo *
 _dbus_user_database_lookup_group (DBusUserDatabase *db,
                                   dbus_gid_t        gid,
                                   const DBusString *groupname,
@@ -328,6 +328,8 @@ _dbus_user_database_lookup_group (DBusUs
           return NULL;
         }
       
+      /* Return a borrowed reference to the DBusGroupInfo owned by the
+       * two hash tables */
       return info;
     }
 }
Index: dbus-1.8.22/dbus/dbus-userdb.c
===================================================================
--- dbus-1.8.22.orig/dbus/dbus-userdb.c
+++ dbus-1.8.22/dbus/dbus-userdb.c
@@ -122,9 +122,9 @@ _dbus_is_a_number (const DBusString *str
  * @param uid the user ID or #DBUS_UID_UNSET
  * @param username username or #NULL 
  * @param error error to fill in
- * @returns the entry in the database
+ * @returns the entry in the database (borrowed, do not free)
  */
-DBusUserInfo*
+const DBusUserInfo *
 _dbus_user_database_lookup (DBusUserDatabase *db,
                             dbus_uid_t        uid,
                             const DBusString *username,
@@ -211,6 +211,8 @@ _dbus_user_database_lookup (DBusUserData
           return NULL;
         }
       
+      /* Return a borrowed pointer to the DBusUserInfo owned by the
+       * hash tables */
       return info;
     }
 }
Index: dbus-1.8.22/dbus/dbus-userdb.h
===================================================================
--- dbus-1.8.22.orig/dbus/dbus-userdb.h
+++ dbus-1.8.22/dbus/dbus-userdb.h
@@ -1,10 +1,10 @@
 /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
 /* dbus-userdb.h User database abstraction
- * 
+ *
  * Copyright (C) 2003  Red Hat, Inc.
  *
  * Licensed under the Academic Free License version 2.1
- * 
+ *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or
@@ -14,7 +14,7 @@
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
- * 
+ *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
@@ -73,11 +73,11 @@ dbus_bool_t       _dbus_user_database_ge
                                                      const DBusGroupInfo **info,
                                                      DBusError            *error);
 
-DBusUserInfo*  _dbus_user_database_lookup       (DBusUserDatabase *db,
+const DBusUserInfo*  _dbus_user_database_lookup       (DBusUserDatabase *db,
                                                  dbus_uid_t        uid,
                                                  const DBusString *username,
                                                  DBusError        *error);
-DBusGroupInfo* _dbus_user_database_lookup_group (DBusUserDatabase *db,
+const DBusGroupInfo* _dbus_user_database_lookup_group (DBusUserDatabase *db,
                                                  dbus_gid_t        gid,
                                                  const DBusString *groupname,
                                                  DBusError        *error);
@@ -105,7 +105,7 @@ dbus_bool_t _dbus_groups_from_uid		(dbus
 dbus_bool_t _dbus_is_console_user               (dbus_uid_t         uid,
                                                  DBusError         *error);
 
-dbus_bool_t _dbus_is_a_number                   (const DBusString *str, 
+dbus_bool_t _dbus_is_a_number                   (const DBusString *str,
                                                  unsigned long    *num);
 
 dbus_bool_t _dbus_username_from_current_process (const DBusString **username);
openSUSE Build Service is sponsored by