!41 【openEuler-22.03-LTS-Next】Fix error of parsing object file perms

From: @yixiangzhike 
Reviewed-by: @xiezhipeng1 
Signed-off-by: @xiezhipeng1
This commit is contained in:
openeuler-ci-bot 2022-08-24 06:40:55 +00:00 committed by Gitee
commit e35f231bf0
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 51 additions and 1 deletions

View File

@ -0,0 +1,46 @@
From 9e18fcfeb2c8ff471c11da58b05215e219be20fd Mon Sep 17 00:00:00 2001
From: yixiangzhike <yixiangzhike007@163.com>
Date: Tue, 16 Aug 2022 09:49:35 +0800
Subject: [PATCH] fix error of parsing object file perms
---
libelf/elf_begin.c | 20 +++++++++++++++++++-
1 file changed, 19 insertions(+), 1 deletion(-)
diff --git a/libelf/elf_begin.c b/libelf/elf_begin.c
index 17d9b1f..581d8ef 100644
--- a/libelf/elf_begin.c
+++ b/libelf/elf_begin.c
@@ -997,10 +997,28 @@ __libelf_next_arhdr_wrlock (Elf *elf)
} \
while (0)
+#define INT_FIELD_HN(FIELD, HN) \
+ do \
+ { \
+ char buf[sizeof (ar_hdr->FIELD) + 1]; \
+ const char *string = ar_hdr->FIELD; \
+ if (ar_hdr->FIELD[sizeof (ar_hdr->FIELD) - 1] != ' ') \
+ { \
+ *((char *) mempcpy (buf, ar_hdr->FIELD, sizeof (ar_hdr->FIELD))) \
+ = '\0'; \
+ string = buf; \
+ } \
+ if (sizeof (elf_ar_hdr->FIELD) <= sizeof (long int)) \
+ elf_ar_hdr->FIELD = (__typeof (elf_ar_hdr->FIELD)) strtol (string, NULL, HN); \
+ else \
+ elf_ar_hdr->FIELD = (__typeof (elf_ar_hdr->FIELD)) strtoll (string, NULL, HN); \
+ } \
+ while (0)
+
INT_FIELD (ar_date);
INT_FIELD (ar_uid);
INT_FIELD (ar_gid);
- INT_FIELD (ar_mode);
+ INT_FIELD_HN (ar_mode, 8);
INT_FIELD (ar_size);
if (elf_ar_hdr->ar_size < 0)
--
2.27.0

View File

@ -1,7 +1,7 @@
# -*- rpm-spec from http://elfutils.org/ -*-
Name: elfutils
Version: 0.185
Release: 7
Release: 8
Summary: A collection of utilities and DSOs to handle ELF files and DWARF data
URL: http://elfutils.org/
License: GPLv3+ and (GPLv2+ or LGPLv3+)
@ -9,6 +9,7 @@ Source: ftp://sourceware.org/pub/elfutils/%{version}/elfutils-%{version}.tar.bz2
Patch0: eu-elfclassify-no-stdin-should-use-classify_flag_no_stdin.patch
Patch1: Fix-segfault-in-eu-ar-m.patch
Patch2: Fix-error-of-parsing-object-file-perms.patch
Provides: elfutils-libelf elfutils-default-yama-scope default-yama-scope elfutils-libs
Obsoletes: elfutils-libelf elfutils-default-yama-scope elfutils-libs
@ -239,6 +240,9 @@ exit 0
%systemd_postun_with_restart debuginfod.service
%changelog
* Tue Aug 16 2022 yixiangzhike <yixiangzhike007@163.com> - 0.185-8
- Fix error of parsing object file perms
* Tue Jul 19 2022 Hugel <gengqihu1@h-partners.com> - 0.185-7
- Add some compression support