diff options
author | Christos Zoulas <christos@zoulas.com> | 2022-12-14 14:24:36 +0000 |
---|---|---|
committer | Christos Zoulas <christos@zoulas.com> | 2022-12-14 14:24:36 +0000 |
commit | 709dfecf25c2eb2822f7e0b8c30d6329cd2d97fb (patch) | |
tree | 431a97ba2de8ca50b34a86ad929c354919222819 | |
parent | d71a0335fdf0be1a4d93ecbdb84bba8c51ad167c (diff) | |
download | file-git-709dfecf25c2eb2822f7e0b8c30d6329cd2d97fb.tar.gz |
Handle nan's so that we don't get internal floating point exceptions
when they are enabled (Vincent Mihalkovic)
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | src/Makefile.am | 4 | ||||
-rw-r--r-- | src/softmagic.c | 19 |
3 files changed, 17 insertions, 11 deletions
@@ -1,3 +1,8 @@ +2022-12-14 9:24 Christos Zoulas <christos@zoulas.com> + + * Handle nan's so that we don't get internal floating point exceptions + when they are enabled (Vincent Mihalkovic) + 2022-10-23 10:21 Christos Zoulas <christos@zoulas.com> * PR/397: Restore the ability to process files from stdin immediately. diff --git a/src/Makefile.am b/src/Makefile.am index 75c1f77b..96749b57 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 cdf.mk BNF memtest.c HDR= $(top_srcdir)/src/magic.h.in diff --git a/src/softmagic.c b/src/softmagic.c index d232b0ec..cff26a45 100644 --- a/src/softmagic.c +++ b/src/softmagic.c @@ -32,11 +32,12 @@ #include "file.h" #ifndef lint -FILE_RCSID("@(#)$File: softmagic.c,v 1.336 2022/12/09 17:58:19 christos Exp $") +FILE_RCSID("@(#)$File: softmagic.c,v 1.337 2022/12/14 14:24:36 christos Exp $") #endif /* lint */ #include "magic.h" #include <assert.h> +#include <math.h> #include <string.h> #include <ctype.h> #include <stdlib.h> @@ -2152,19 +2153,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: @@ -2185,19 +2186,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: |