import file-5.39-12.el9

i9c changed/i9c/file-5.39-12.el9
MSVSphere Packaging Team 2 years ago
parent 664e66deb6
commit 21a29d5658

@ -0,0 +1,77 @@
diff --git a/src/Makefile.am b/src/Makefile.am
index b43cb8e..93d6625 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -17,10 +17,10 @@ MINGWLIBS = -lgnurx -lshlwapi
else
MINGWLIBS =
endif
-libmagic_la_LIBADD = $(LTLIBOBJS) $(MINGWLIBS)
+libmagic_la_LIBADD = -lm $(LTLIBOBJS) $(MINGWLIBS)
file_SOURCES = file.c seccomp.c
-file_LDADD = libmagic.la
+file_LDADD = libmagic.la -lm
CLEANFILES = magic.h
EXTRA_DIST = magic.h.in
HDR= $(top_srcdir)/src/magic.h.in
diff --git a/src/softmagic.c b/src/softmagic.c
index becc53c..39c7e0b 100644
--- a/src/softmagic.c
+++ b/src/softmagic.c
@@ -37,6 +37,7 @@ FILE_RCSID("@(#)$File: softmagic.c,v 1.299 2020/06/07 21:58:01 christos Exp $")
#include "magic.h"
#include <assert.h>
+#include <math.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
@@ -2074,19 +2075,19 @@ magiccheck(struct magic_set *ms, struct magic *m, file_regex_t **m_cache)
break;
case '!':
- matched = fv != fl;
+ matched = isunordered(fl, fv) ? 1 : fv != fl;
break;
case '=':
- matched = fv == fl;
+ matched = isunordered(fl, fv) ? 0 : fv == fl;
break;
case '>':
- matched = fv > fl;
+ matched = isgreater(fv, fl);
break;
case '<':
- matched = fv < fl;
+ matched = isless(fv, fl);
break;
default:
@@ -2107,19 +2108,19 @@ magiccheck(struct magic_set *ms, struct magic *m, file_regex_t **m_cache)
break;
case '!':
- matched = dv != dl;
+ matched = isunordered(dv, dl) ? 1 : dv != dl;
break;
case '=':
- matched = dv == dl;
+ matched = isunordered(dv, dl) ? 0 : dv == dl;
break;
case '>':
- matched = dv > dl;
+ matched = isgreater(dv, dl);
break;
case '<':
- matched = dv < dl;
+ matched = isless(dv, dl);
break;
default:

@ -0,0 +1,130 @@
From 363d7fcf703ad3ebf37b45693b2c9e43eb8b4176 Mon Sep 17 00:00:00 2001
From: Christos Zoulas <christos@zoulas.com>
Date: Sat, 22 Aug 2020 18:04:18 +0000
Subject: [PATCH] Improve detection of static-pie binaries, and don't call them
"dynamically linked", but call them "static-pie" linked.
---
src/readelf.c | 37 ++++++++++++++++++++++++++-----------
1 file changed, 26 insertions(+), 11 deletions(-)
diff --git a/src/readelf.c b/src/readelf.c
index cf1dc91b7..d390d5f6a 100644
--- a/src/readelf.c
+++ b/src/readelf.c
@@ -27,7 +27,7 @@
#include "file.h"
#ifndef lint
-FILE_RCSID("@(#)$File: readelf.c,v 1.173 2020/06/07 22:12:54 christos Exp $")
+FILE_RCSID("@(#)$File: readelf.c,v 1.174 2020/08/22 18:04:18 christos Exp $")
#endif
#ifdef BUILTIN_ELF
@@ -1099,7 +1099,7 @@ do_auxv_note(struct magic_set *ms, unsigned char *nbuf, uint32_t type,
private size_t
dodynamic(struct magic_set *ms, void *vbuf, size_t offset, size_t size,
- int clazz, int swap)
+ int clazz, int swap, int *pie, size_t *need)
{
Elf32_Dyn dh32;
Elf64_Dyn dh64;
@@ -1117,11 +1117,15 @@ dodynamic(struct magic_set *ms, void *vbuf, size_t offset, size_t size,
switch (xdh_tag) {
case DT_FLAGS_1:
+ *pie = 1;
if (xdh_val & DF_1_PIE)
ms->mode |= 0111;
else
ms->mode &= ~0111;
break;
+ case DT_NEEDED:
+ (*need)++;
+ break;
default:
break;
}
@@ -1608,9 +1612,10 @@ doshn(struct magic_set *ms, int clazz, int swap, int fd, off_t off, int num,
}
/*
- * Look through the program headers of an executable image, searching
- * for a PT_INTERP section; if one is found, it's dynamically linked,
- * otherwise it's statically linked.
+ * Look through the program headers of an executable image, to determine
+ * if it is statically or dynamically linked. If it has a dynamic section,
+ * it is pie, and does not have an interpreter or needed libraries, we
+ * call it static pie.
*/
private int
dophn_exec(struct magic_set *ms, int clazz, int swap, int fd, off_t off,
@@ -1619,12 +1624,13 @@ dophn_exec(struct magic_set *ms, int clazz, int swap, int fd, off_t off,
{
Elf32_Phdr ph32;
Elf64_Phdr ph64;
- const char *linking_style = "statically";
+ const char *linking_style;
unsigned char nbuf[BUFSIZ];
char ibuf[BUFSIZ];
char interp[BUFSIZ];
ssize_t bufsize;
- size_t offset, align, len;
+ size_t offset, align, len, need = 0;
+ int pie = 0, dynamic = 0;
if (num == 0) {
if (file_printf(ms, ", no program header") == -1)
@@ -1654,7 +1660,6 @@ dophn_exec(struct magic_set *ms, int clazz, int swap, int fd, off_t off,
switch (xph_type) {
case PT_DYNAMIC:
doread = 1;
- linking_style = "dynamically";
break;
case PT_NOTE:
if (sh_num) /* Did this through section headers */
@@ -1694,6 +1699,7 @@ dophn_exec(struct magic_set *ms, int clazz, int swap, int fd, off_t off,
/* Things we can determine when we seek */
switch (xph_type) {
case PT_DYNAMIC:
+ dynamic = 1;
offset = 0;
// Let DF_1 determine if we are PIE or not.
ms->mode &= ~0111;
@@ -1701,7 +1707,8 @@ dophn_exec(struct magic_set *ms, int clazz, int swap, int fd, off_t off,
if (offset >= CAST(size_t, bufsize))
break;
offset = dodynamic(ms, nbuf, offset,
- CAST(size_t, bufsize), clazz, swap);
+ CAST(size_t, bufsize), clazz, swap,
+ &pie, &need);
if (offset == 0)
break;
}
@@ -1710,6 +1717,7 @@ dophn_exec(struct magic_set *ms, int clazz, int swap, int fd, off_t off,
break;
case PT_INTERP:
+ need++;
if (ms->flags & MAGIC_MIME)
continue;
if (bufsize && nbuf[0]) {
@@ -1744,8 +1752,15 @@ dophn_exec(struct magic_set *ms, int clazz, int swap, int fd, off_t off,
}
if (ms->flags & MAGIC_MIME)
return 0;
- if (file_printf(ms, ", %s linked", linking_style)
- == -1)
+ if (dynamic) {
+ if (pie && need == 0)
+ linking_style = "static-pie";
+ else
+ linking_style = "dynamically";
+ } else {
+ linking_style = "statically";
+ }
+ if (file_printf(ms, ", %s linked", linking_style) == -1)
return -1;
if (interp[0])
if (file_printf(ms, ", interpreter %s",

@ -15,7 +15,7 @@
Summary: Utility for determining file types
Name: file
Version: 5.39
Release: 10%{?dist}
Release: 12%{?dist}
License: BSD
Source0: http://ftp.astron.com/pub/file/file-%{version}.tar.gz
@ -49,6 +49,10 @@ Patch10: file-5.39-regex-combinations.patch
Patch11: file-5.39-regex-escape.patch
# Upstream commit 14b5d7aa0b55275969809fdf84e8a8caee857c0f (#2120692)
Patch12: file-5.39-regex-optimalizations.patch
# Upstream commit 709dfecf25c2eb2822f7e0b8c30d6329cd2d97fb (#2164840)
Patch13: file-5.39-floating-point-exception.patch
# Upstream commit 363d7fcf703ad3ebf37b45693b2c9e43eb8b4176 (#2164834)
Patch14: file-5.39-static-PIE-binaries.patch
URL: https://www.darwinsys.com/file/
Requires: file-libs%{?_isa} = %{version}-%{release}
@ -231,6 +235,14 @@ cd %{py3dir}
* Wed Mar 15 2023 MSVSphere Packaging Team <packager@msvsphere.ru> - 5.39-10
- Rebuilt for MSVSphere 9.1.
* Wed Feb 01 2023 Vincent Mihalkovic <vmihalko@redhat.com> - 5.39-12
- fix detection of static-pie binaries
Resolves: #2164834
* Tue Jan 31 2023 Vincent Mihalkovic <vmihalko@redhat.com> - 5.39-11
- fix issue with libmagic and floating point exceptions
Resolves: #2061557
* Wed Aug 24 2022 Vincent Mihalkovic <vmihalko@redhat.com> - 5.39-10
- speedup magic matching
Resolves: #2120692

Loading…
Cancel
Save