Skip to content

Commit d92a87d

Browse files
committed
Fixed bug #68671 incorrect expression in libmagic
1 parent 211f4ce commit d92a87d

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ PHP NEWS
2525
. Fixed bug #67643 (curl_multi_getcontent returns '' when
2626
CURLOPT_RETURNTRANSFER isn't set). (Jille Timmermans)
2727

28+
- Fileinfo:
29+
. Fixed bug #68671 (incorrect expression in libmagic).
30+
(Joshua Rogers, Anatol Belski)
31+
2832
- GD:
2933
. Fixed bug #68601 (buffer read overflow in gd_gif_in.c). (Jan Bee, Remi)
3034

ext/fileinfo/libmagic/print.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,16 +59,19 @@ protected void
5959
file_magwarn(struct magic_set *ms, const char *f, ...)
6060
{
6161
va_list va;
62-
char *expanded_format;
62+
char *expanded_format = NULL;
63+
int expanded_len;
6364
TSRMLS_FETCH();
6465

6566
va_start(va, f);
66-
if (vasprintf(&expanded_format, f, va)); /* silence */
67+
expanded_len = vasprintf(&expanded_format, f, va);
6768
va_end(va);
6869

69-
php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Warning: %s", expanded_format);
70+
if (expanded_len >= 0 && expanded_format) {
71+
php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Warning: %s", expanded_format);
7072

71-
free(expanded_format);
73+
free(expanded_format);
74+
}
7275
}
7376

7477
protected const char *

0 commit comments

Comments
 (0)