Hi,

I have noticed that tests of misc/p5-File-LibMagic were failing
since devel/libmagic has been updated.

Version 5.47 introduced a bug that was fixed later.  I would like
to backport the fixes.  With that p5-File-LibMagic tests pass.

ok?

bluhm

Index: devel/libmagic/Makefile
===================================================================
RCS file: /data/mirror/openbsd/cvs/ports/devel/libmagic/Makefile,v
diff -u -p -r1.55 Makefile
--- devel/libmagic/Makefile     2 Mar 2026 16:22:52 -0000       1.55
+++ devel/libmagic/Makefile     12 May 2026 22:30:46 -0000
@@ -3,6 +3,7 @@ COMMENT=        library to determine file type
 V=             5.47
 DISTNAME=      file-${V}
 PKGNAME=       libmagic-${V}
+REVISION=      0
 
 SHARED_LIBS +=  magic                5.1      # 1.0
 
Index: devel/libmagic/patches/patch-src_softmagic_c
===================================================================
RCS file: devel/libmagic/patches/patch-src_softmagic_c
diff -N devel/libmagic/patches/patch-src_softmagic_c
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ devel/libmagic/patches/patch-src_softmagic_c        12 May 2026 22:38:01 
-0000
@@ -0,0 +1,48 @@
+https://github.com/file/file
+
+Bug introduced in 5.47
+
+commit 08ab5f644bf9822c64faf5efa4e393b58d7bcd0e
+Author: Christos Zoulas <[email protected]>
+Date:   Wed May 28 19:22:22 2025 +0000
+
+    PR/622: Odd_Bloke: Handle negative offsets in file_buffer(), when fd is not
+    available.
+
+Backport two bug fixes from master.
+
+commit b75b4ac5861ee2207b8bf186e1967602a08fda40
+Author: Christos Zoulas <[email protected]>
+Date:   Sat May 9 22:14:09 2026 +0000
+
+    Add missing check to prevent subtraction underflow.
+    (evilrabbit @ tutamail dot com)
+
+commit c54605718190ad8fe9c25cb475f1f32ca7cd54f7
+Author: Christos Zoulas <[email protected]>
+Date:   Sun Apr 12 22:15:14 2026 +0000
+
+    PR/725: inliniac: Revert previous and always set offset.
+
+Index: src/softmagic.c
+--- src/softmagic.c.orig
++++ src/softmagic.c
+@@ -1562,6 +1562,8 @@ msetoffset(struct magic_set *ms, struct magic *m, stru
+                       return -1;
+               }
+               if (b->fd == -1) {
++                      if (CAST(size_t, m->offset) > b->flen)
++                              return -1;
+                       ms->eoffset = ms->offset =
+                           CAST(int32_t, b->flen - m->offset);
+               } else {
+@@ -1580,8 +1582,7 @@ normal:
+                       ms->offset = offset;
+                       ms->eoffset = 0;
+               } else {
+-                      if (b->fd != -1)
+-                              ms->offset = ms->eoffset + offset;
++                      ms->offset = ms->eoffset + offset;
+               }
+       }
+       if ((ms->flags & MAGIC_DEBUG) != 0) {

Reply via email to