Resolves: #2164840 - fix issue with floating point exceptions

This commit is contained in:
Vincent Mihalkovic 2023-01-31 17:28:55 +01:00
parent 9882f5663a
commit e8ba9fa7bd
2 changed files with 84 additions and 1 deletions

View File

@ -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:

View File

@ -15,7 +15,7 @@
Summary: Utility for determining file types
Name: file
Version: 5.39
Release: 10%{?dist}
Release: 11%{?dist}
License: BSD
Source0: http://ftp.astron.com/pub/file/file-%{version}.tar.gz
@ -49,6 +49,8 @@ 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
URL: https://www.darwinsys.com/file/
Requires: file-libs%{?_isa} = %{version}-%{release}
@ -228,6 +230,10 @@ cd %{py3dir}
%endif
%changelog
* 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