Skip to content

Commit 3f286fa

Browse files
committed
Promote Notice to Warning in libmagic
The current behaviour makes little to no sense, having a notice which starts with 'Warning:' should just be a warning Closes GH-5824
1 parent 6556846 commit 3f286fa

File tree

5 files changed

+20
-20
lines changed

5 files changed

+20
-20
lines changed

ext/fileinfo/libmagic.patch

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1062,7 +1062,7 @@ diff -u libmagic.orig/buffer.c libmagic/buffer.c
10621062

10631063
diff -u libmagic.orig/cdf.c libmagic/cdf.c
10641064
--- libmagic.orig/cdf.c 2019-02-20 03:35:27.000000000 +0100
1065-
+++ libmagic/cdf.c 2020-04-07 22:25:10.517321000 +0200
1065+
+++ libmagic/cdf.c 2020-05-05 20:05:37.698461100 +0200
10661066
@@ -43,7 +43,17 @@
10671067
#include <err.h>
10681068
#endif
@@ -1395,7 +1395,7 @@ diff -u libmagic.orig/cdf_time.c libmagic/cdf_time.c
13951395
(void)snprintf(buf, 26, "*Bad* %#16.16" INT64_T_FORMAT "x\n",
13961396
diff -u libmagic.orig/compress.c libmagic/compress.c
13971397
--- libmagic.orig/compress.c 2019-05-07 04:27:11.000000000 +0200
1398-
+++ libmagic/compress.c 2020-04-07 22:25:10.517321000 +0200
1398+
+++ libmagic/compress.c 2020-06-17 02:13:31.620121400 +0200
13991399
@@ -45,13 +45,11 @@
14001400
#endif
14011401
#include <string.h>
@@ -1636,7 +1636,7 @@ diff -u libmagic.orig/encoding.c libmagic/encoding.c
16361636
}
16371637
diff -u libmagic.orig/file.h libmagic/file.h
16381638
--- libmagic.orig/file.h 2019-05-07 04:27:11.000000000 +0200
1639-
+++ libmagic/file.h 2020-04-22 20:15:46.790840100 +0200
1639+
+++ libmagic/file.h 2020-06-21 00:23:48.421548900 +0200
16401640
@@ -33,18 +33,9 @@
16411641
#ifndef __file_h__
16421642
#define __file_h__
@@ -2212,7 +2212,7 @@ diff -u libmagic.orig/fsmagic.c libmagic/fsmagic.c
22122212
case S_IFSOCK:
22132213
diff -u libmagic.orig/funcs.c libmagic/funcs.c
22142214
--- libmagic.orig/funcs.c 2019-05-07 04:27:11.000000000 +0200
2215-
+++ libmagic/funcs.c 2020-04-14 17:15:50.737587100 +0200
2215+
+++ libmagic/funcs.c 2020-06-17 02:13:31.651362400 +0200
22162216
@@ -31,87 +31,80 @@
22172217
#endif /* lint */
22182218

@@ -3048,7 +3048,7 @@ diff -u libmagic.orig/magic.c libmagic/magic.c
30483048
public const char *
30493049
magic_error(struct magic_set *ms)
30503050
diff -u libmagic.orig/magic.h libmagic/magic.h
3051-
--- libmagic.orig/magic.h 2020-04-22 20:17:15.432186600 +0200
3051+
--- libmagic.orig/magic.h 2020-07-08 18:10:37.403232400 +0200
30523052
+++ libmagic/magic.h 2020-04-07 22:25:10.548560600 +0200
30533053
@@ -124,6 +124,7 @@
30543054

@@ -3060,7 +3060,7 @@ diff -u libmagic.orig/magic.h libmagic/magic.h
30603060

30613061
diff -u libmagic.orig/print.c libmagic/print.c
30623062
--- libmagic.orig/print.c 2019-03-12 21:43:05.000000000 +0100
3063-
+++ libmagic/print.c 2020-04-07 22:25:10.548560600 +0200
3063+
+++ libmagic/print.c 2020-07-08 18:05:40.114527900 +0200
30643064
@@ -28,6 +28,7 @@
30653065
/*
30663066
* print.c - debugging printout routines
@@ -3108,7 +3108,7 @@ diff -u libmagic.orig/print.c libmagic/print.c
31083108
- (void) fputc('\n', stderr);
31093109
+
31103110
+ if (expanded_len >= 0 && expanded_format) {
3111-
+ php_error_docref(NULL, E_NOTICE, "Warning: %s", expanded_format);
3111+
+ php_error_docref(NULL, E_WARNING, "%s", expanded_format);
31123112
+
31133113
+ free(expanded_format);
31143114
+ }
@@ -3253,7 +3253,7 @@ diff -u libmagic.orig/readcdf.c libmagic/readcdf.c
32533253
if (i != -1)
32543254
diff -u libmagic.orig/softmagic.c libmagic/softmagic.c
32553255
--- libmagic.orig/softmagic.c 2019-05-17 04:24:59.000000000 +0200
3256-
+++ libmagic/softmagic.c 2020-04-07 22:25:10.548560600 +0200
3256+
+++ libmagic/softmagic.c 2020-04-26 00:43:35.734037100 +0200
32573257
@@ -43,6 +43,10 @@
32583258
#include <time.h>
32593259
#include "der.h"

ext/fileinfo/libmagic/print.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ file_magwarn(struct magic_set *ms, const char *f, ...)
226226
va_end(va);
227227

228228
if (expanded_len >= 0 && expanded_format) {
229-
php_error_docref(NULL, E_NOTICE, "Warning: %s", expanded_format);
229+
php_error_docref(NULL, E_WARNING, "%s", expanded_format);
230230

231231
free(expanded_format);
232232
}

ext/fileinfo/tests/bug61964-mb.phpt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,15 @@ bool(false)%A
4848
resource(%d) of type (file_info)
4949
resource(%d) of type (file_info)
5050
bool(false)%A
51-
Notice: finfo_open(): Warning: offset `string' invalid in %sbug61964-mb.php on line %d
51+
Warning: finfo_open(): offset `string' invalid in %sbug61964-mb.php on line %d
5252

53-
Notice: finfo_open(): Warning: offset ` Core' invalid in %sbug61964-mb.php on line %d
53+
Warning: finfo_open(): offset ` Core' invalid in %sbug61964-mb.php on line %d
5454

55-
Notice: finfo_open(): Warning: offset ` Me' invalid in %sbug61964-mb.php on line %d
55+
Warning: finfo_open(): offset ` Me' invalid in %sbug61964-mb.php on line %d
5656

57-
Notice: finfo_open(): Warning: offset `a' invalid in %sbug61964-mb.php on line %d
57+
Warning: finfo_open(): offset `a' invalid in %sbug61964-mb.php on line %d
5858

59-
Notice: finfo_open(): Warning: offset `b' invalid in %sbug61964-mb.php on line %d
59+
Warning: finfo_open(): offset `b' invalid in %sbug61964-mb.php on line %d
6060

6161
Warning: finfo_open(): Failed to load magic database at '%sbug61964-mb'. in %sbug61964-mb.php on line %d
6262
DONE: testing dir with files

ext/fileinfo/tests/bug61964.phpt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,15 @@ bool(false)%A
4848
resource(%d) of type (file_info)
4949
resource(%d) of type (file_info)
5050
bool(false)%A
51-
Notice: finfo_open(): Warning: offset `string' invalid in %sbug61964.php on line %d
51+
Warning: finfo_open(): offset `string' invalid in %sbug61964.php on line %d
5252

53-
Notice: finfo_open(): Warning: offset ` Core' invalid in %sbug61964.php on line %d
53+
Warning: finfo_open(): offset ` Core' invalid in %sbug61964.php on line %d
5454

55-
Notice: finfo_open(): Warning: offset ` Me' invalid in %sbug61964.php on line %d
55+
Warning: finfo_open(): offset ` Me' invalid in %sbug61964.php on line %d
5656

57-
Notice: finfo_open(): Warning: offset `a' invalid in %sbug61964.php on line %d
57+
Warning: finfo_open(): offset `a' invalid in %sbug61964.php on line %d
5858

59-
Notice: finfo_open(): Warning: offset `b' invalid in %sbug61964.php on line %d
59+
Warning: finfo_open(): offset `b' invalid in %sbug61964.php on line %d
6060

6161
Warning: finfo_open(): Failed to load magic database at '%sbug61964'. in %sbug61964.php on line %d
6262
DONE: testing dir with files

ext/fileinfo/tests/finfo_open_error.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Warning: finfo_open(%sfoobarfile): Failed to open stream: No such file or direct
3434
Warning: finfo_open(): Failed to load magic database at '%sfoobarfile'. in %sfinfo_open_error.php on line %d
3535
bool(false)
3636

37-
Notice: finfo_open(): Warning: using regular magic file `%smagic' in %sfinfo_open_error.php on line %d
37+
Warning: finfo_open(): using regular magic file `%smagic' in %sfinfo_open_error.php on line %d
3838
resource(6) of type (file_info)
3939
finfo_open(): Argument #1 ($options) must be of type int, string given
4040
finfo::__construct(): Argument #1 ($options) must be of type int, string given

0 commit comments

Comments
 (0)