acl/0029-getfacl-Fix-minor-resource-leak.patch
Marcus Meissner 5439477a49 Accepting request 347209 from home:jeff_mahoney:branches:Base:System
- Update to git snapshot dated 21 Sep 2015.
  - Added:
    * 0001-Install-the-libraries-to-the-appropriate-directory.patch
    * 0002-setfacl.1-fix-typo-inclu-de-include.patch
    * 0003-test-fix-insufficient-quoting-of.patch
    * 0004-Makefile-rename-configure.in-to-configure.ac.patch
    * 0005-Bad-markup-in-acl.5-page.patch
    * 0006-.gitignore-ignore-and-config.h.in.patch
    * 0007-Use-autoreconf-rather-than-autoconf-to-regenerate-th.patch
    * 0008-libacl-Make-sure-that-acl_from_text-always-sets-errn.patch
    * 0009-libacl-fix-SIGSEGV-of-getfacl-e-on-overly-long-group.patch
    * 0010-punt-debian-rpm-packaging-logic.patch
    * 0011-move-gettext-logic-into-misc.h.patch
    * 0012-test-make-running-parallel-out-of-tree-safe.patch
    * 0013-modernize-build-system.patch
    * 0014-po-regenerate-files-after-move.patch
    * 0015-build-drop-aclincludedir-use-pkgincludedir.patch
    * 0016-build-make-use-of-an-aux-dir-to-stow-away-helper-scr.patch
    * 0017-build-ship-a-pkgconfig-file-for-libacl.patch
    * 0018-read_acl_-comments-seq-rename-line-to-lineno.patch
    * 0019-read_acl_-comments-seq-switch-to-next_line.patch
    * 0020-telldir-return-value-and-seekdir-second-parameters-a.patch
    * 0021-mark-libmisc-funcs-as-hidden-so-they-are-not-exporte.patch
    * 0022-add-__acl_-prefixes-to-internal-symbols.patch
    * 0023-cp.test-Check-permissions-of-the-right-file.patch
    * 0024-libacl-acl_set_file-Remove-unnecesary-racy-check.patch
    * 0025-fix-compilation-with-latest-xattr-git.patch
    * 0026-getfacl-Fix-memory-leak.patch
    * 0027-Fix-the-display-block-nesting-in-acl.5.patch
    * 0028-setfacl-man-page-Minor-wording-improvements.patch

OBS-URL: https://build.opensuse.org/request/show/347209
OBS-URL: https://build.opensuse.org/package/show/Base:System/acl?expand=0&rev=43
2015-12-03 14:58:36 +00:00

86 lines
2.4 KiB
Diff

From 519e3932898baba1e7eeb0d9d89acee796da61f5 Mon Sep 17 00:00:00 2001
From: Andreas Gruenbacher <agruenba@redhat.com>
Date: Tue, 8 Sep 2015 14:23:58 +0200
Subject: [PATCH 29/34] getfacl: Fix minor resource leak
The return value of of acl_get_qualifier needs to be acl_freed.
Reported by Jaska Uimonen <jaska.uimonen@helsinki.fi>.
---
tools/getfacl.c | 31 ++++++++++++++++++++-----------
1 file changed, 20 insertions(+), 11 deletions(-)
diff --git a/tools/getfacl.c b/tools/getfacl.c
index e44b572..3d8f1b8 100644
--- a/tools/getfacl.c
+++ b/tools/getfacl.c
@@ -125,7 +125,7 @@ struct name_list *get_list(const struct stat *st, acl_t acl)
return NULL;
while (ret > 0) {
acl_tag_t e_type;
- const id_t *id_p;
+ id_t *id_p;
const char *name = "";
int len;
@@ -137,8 +137,10 @@ struct name_list *get_list(const struct stat *st, acl_t acl)
case ACL_USER:
id_p = acl_get_qualifier(ent);
- if (id_p != NULL)
+ if (id_p != NULL) {
name = user_name(*id_p, opt_numeric);
+ acl_free(id_p);
+ }
break;
case ACL_GROUP_OBJ:
@@ -147,8 +149,10 @@ struct name_list *get_list(const struct stat *st, acl_t acl)
case ACL_GROUP:
id_p = acl_get_qualifier(ent);
- if (id_p != NULL)
+ if (id_p != NULL) {
name = group_name(*id_p, opt_numeric);
+ acl_free(id_p);
+ }
break;
}
name = xquote(name, "\t\n\r");
@@ -378,19 +382,24 @@ int do_show(FILE *stream, const char *path_p, const struct stat *st,
continue;
} else {
if (acl_tag == ACL_USER || acl_tag == ACL_GROUP) {
- id_t *acl_id_p = NULL, *dacl_id_p = NULL;
- if (acl_ent)
- acl_id_p = acl_get_qualifier(acl_ent);
- if (dacl_ent)
- dacl_id_p = acl_get_qualifier(dacl_ent);
+ int id_cmp = 0;
+
+ if (acl_ent && dacl_ent) {
+ id_t *acl_id_p = acl_get_qualifier(acl_ent);
+ id_t *dacl_id_p = acl_get_qualifier(dacl_ent);
+
+ id_cmp = (*acl_id_p > *dacl_id_p) -
+ (*acl_id_p < *dacl_id_p);
+ acl_free(acl_id_p);
+ acl_free(dacl_id_p);
+ }
- if (acl && (!dacl || *acl_id_p < *dacl_id_p)) {
+ if (acl && (!dacl || id_cmp < 0)) {
show_line(stream, &acl_names, acl,
&acl_ent, acl_mask,
NULL, NULL, NULL, NULL);
continue;
- } else if (dacl &&
- (!acl || *dacl_id_p < *acl_id_p)) {
+ } else if (dacl && (!acl || id_cmp > 0)) {
show_line(stream, NULL, NULL, NULL,
NULL, &dacl_names, dacl,
&dacl_ent, dacl_mask);
--
2.5.2