1
1
diff -u libmagic.orig/apprentice.c libmagic/apprentice.c
2
2
--- libmagic.orig/apprentice.c 2013-03-21 18:45:14.000000000 +0100
3
- +++ libmagic/apprentice.c 2013-04-08 16:14:17.828357711 +0200
3
+ +++ libmagic/apprentice.c 2013-04-27 13:53:32.175250261 +0200
4
4
@@ -29,6 +29,8 @@
5
5
* apprentice - make one pass through /etc/magic, learning its secrets.
6
6
*/
@@ -352,7 +352,7 @@ diff -u libmagic.orig/apprentice.c libmagic/apprentice.c
352
352
file_oomem(ms, slen);
353
353
return -1;
354
354
}
355
- @@ -1102,14 +1121,14 @@
355
+ @@ -1102,27 +1121,29 @@
356
356
if (me == NULL)
357
357
return;
358
358
for (i = 0; i < nme; i++)
@@ -370,8 +370,9 @@ diff -u libmagic.orig/apprentice.c libmagic/apprentice.c
370
370
struct magic_entry *mentry[MAGIC_SETS] = { NULL };
371
371
uint32_t mentrycount[MAGIC_SETS] = { 0 };
372
372
uint32_t i, j;
373
- @@ -1117,12 +1136,14 @@
374
- char **filearr = NULL, *mfn;
373
+ size_t files = 0, maxfiles = 0;
374
+ - char **filearr = NULL, *mfn;
375
+ + char **filearr = NULL;
375
376
struct stat st;
376
377
struct magic_map *map;
377
378
- DIR *dir;
@@ -411,7 +412,7 @@ diff -u libmagic.orig/apprentice.c libmagic/apprentice.c
411
412
+ int mflen;
412
413
+ char mfn[MAXPATHLEN];
413
414
+
414
- + dir = php_stream_opendir(fn, REPORT_ERRORS, NULL);
415
+ + dir = php_stream_opendir((char *) fn, REPORT_ERRORS, NULL);
415
416
if (!dir) {
416
417
errs++;
417
418
goto out;
@@ -578,7 +579,7 @@ diff -u libmagic.orig/apprentice.c libmagic/apprentice.c
578
579
+ #ifdef PHP_WIN32
579
580
+ /* Don't bother on windows with php_stream_open_wrapper,
580
581
+ return to give apprentice_load() a chance. */
581
- + if (php_stream_stat_path_ex(fn, 0, &st, NULL) == SUCCESS) {
582
+ + if (php_stream_stat_path_ex((char *) fn, 0, &st, NULL) == SUCCESS) {
582
583
+ if (st.sb.st_mode & S_IFDIR) {
583
584
+ goto error;
584
585
+ }
@@ -751,7 +752,7 @@ diff -u libmagic.orig/apprentice.c libmagic/apprentice.c
751
752
}
752
753
753
754
- if (write(fd, map->nmagic, nm) != (ssize_t)nm) {
754
- + if (php_stream_write(stream, map->nmagic, nm) != (ssize_t)nm) {
755
+ + if (php_stream_write(stream, (const char *) map->nmagic, nm) != (ssize_t)nm) {
755
756
file_error(ms, errno, "error writing `%s'", dbname);
756
757
goto out;
757
758
}
@@ -767,7 +768,7 @@ diff -u libmagic.orig/apprentice.c libmagic/apprentice.c
767
768
for (i = 0; i < MAGIC_SETS; i++) {
768
769
len = m * map->nmagic[i];
769
770
- if (write(fd, map->magic[i], len) != (ssize_t)len) {
770
- + if (php_stream_write(stream, map->magic[i], len) != (ssize_t)len) {
771
+ + if (php_stream_write(stream, (const char *) map->magic[i], len) != (ssize_t)len) {
771
772
file_error(ms, errno, "error writing `%s'", dbname);
772
773
goto out;
773
774
}
@@ -2047,7 +2048,7 @@ diff -u libmagic.orig/funcs.c libmagic/funcs.c
2047
2048
+
2048
2049
diff -u libmagic.orig/magic.c libmagic/magic.c
2049
2050
--- libmagic.orig/magic.c 2013-01-11 17:43:09.000000000 +0100
2050
- +++ libmagic/magic.c 2013-04-08 15:42:57.328298809 +0200
2051
+ +++ libmagic/magic.c 2013-04-27 13:53:32.175250261 +0200
2051
2052
@@ -25,11 +25,6 @@
2052
2053
* SUCH DAMAGE.
2053
2054
*/
@@ -2089,7 +2090,7 @@ diff -u libmagic.orig/magic.c libmagic/magic.c
2089
2090
#if defined(HAVE_UTIMES)
2090
2091
# include <sys/time.h>
2091
2092
#elif defined(HAVE_UTIME)
2092
- @@ -71,18 +75,24 @@
2093
+ @@ -71,18 +75,25 @@
2093
2094
#endif
2094
2095
#endif
2095
2096
@@ -2098,14 +2099,14 @@ diff -u libmagic.orig/magic.c libmagic/magic.c
2098
2099
+ # undef S_IFIFO
2099
2100
+ #endif
2100
2101
+
2101
- + private void free_mlist(struct mlist *);
2102
2102
private void close_and_restore(const struct magic_set *, const char *, int,
2103
2103
const struct stat *);
2104
2104
private int unreadable_info(struct magic_set *, mode_t, const char *);
2105
+ + #if 0
2105
2106
private const char* get_default_magic(void);
2106
2107
- #ifndef COMPILE_ONLY
2107
2108
- private const char *file_or_fd(struct magic_set *, const char *, int);
2108
- - #endif
2109
+ #endif
2109
2110
+ private const char *file_or_stream(struct magic_set *, const char *, php_stream *);
2110
2111
2111
2112
#ifndef STDIN_FILENO
@@ -2117,7 +2118,7 @@ diff -u libmagic.orig/magic.c libmagic/magic.c
2117
2118
private const char *
2118
2119
get_default_magic(void)
2119
2120
{
2120
- @@ -90,7 +100 ,7 @@
2121
+ @@ -90,7 +101 ,7 @@
2121
2122
static char *default_magic;
2122
2123
char *home, *hmagicpath;
2123
2124
@@ -2126,7 +2127,7 @@ diff -u libmagic.orig/magic.c libmagic/magic.c
2126
2127
struct stat st;
2127
2128
2128
2129
if (default_magic) {
2129
- @@ -104,17 +114 ,17 @@
2130
+ @@ -104,17 +115 ,17 @@
2130
2131
return MAGIC;
2131
2132
if (stat(hmagicpath, &st) == -1) {
2132
2133
free(hmagicpath);
@@ -2153,15 +2154,15 @@ diff -u libmagic.orig/magic.c libmagic/magic.c
2153
2154
}
2154
2155
2155
2156
if (asprintf(&default_magic, "%s:%s", hmagicpath, MAGIC) < 0)
2156
- @@ -128,6 +138 ,7 @@
2157
+ @@ -128,6 +139 ,7 @@
2157
2158
#else
2158
2159
char *hmagicp = hmagicpath;
2159
2160
char *tmppath = NULL;
2160
2161
+ LPTSTR dllpath;
2161
2162
2162
2163
#define APPENDPATH() \
2163
2164
do { \
2164
- @@ -172,7 +183 ,7 @@
2165
+ @@ -172,7 +184 ,7 @@
2165
2166
}
2166
2167
2167
2168
/* Third, try to get magic file relative to dll location */
@@ -2170,15 +2171,15 @@ diff -u libmagic.orig/magic.c libmagic/magic.c
2170
2171
dllpath[MAX_PATH] = 0; /* just in case long path gets truncated and not null terminated */
2171
2172
if (GetModuleFileNameA(NULL, dllpath, MAX_PATH)){
2172
2173
PathRemoveFileSpecA(dllpath);
2173
- @@ -210,6 +221 ,7 @@
2174
+ @@ -210,6 +222 ,7 @@
2174
2175
2175
2176
return action == FILE_LOAD ? get_default_magic() : MAGIC;
2176
2177
}
2177
2178
+ #endif
2178
2179
2179
2180
public struct magic_set *
2180
2181
magic_open(int flags)
2181
- @@ -250,7 +262 ,7 @@
2182
+ @@ -250,7 +263 ,7 @@
2182
2183
magic_load(struct magic_set *ms, const char *magicfile)
2183
2184
{
2184
2185
if (ms == NULL)
@@ -2187,7 +2188,7 @@ diff -u libmagic.orig/magic.c libmagic/magic.c
2187
2188
return file_apprentice(ms, magicfile, FILE_LOAD);
2188
2189
}
2189
2190
2190
- @@ -262,13 +274 ,6 @@
2191
+ @@ -262,13 +275 ,6 @@
2191
2192
return file_apprentice(ms, magicfile, FILE_COMPILE);
2192
2193
}
2193
2194
@@ -2201,7 +2202,7 @@ diff -u libmagic.orig/magic.c libmagic/magic.c
2201
2202
2202
2203
public int
2203
2204
magic_list(struct magic_set *ms, const char *magicfile)
2204
- @@ -282,9 +287 ,6 @@
2205
+ @@ -282,9 +288 ,6 @@
2205
2206
close_and_restore(const struct magic_set *ms, const char *name, int fd,
2206
2207
const struct stat *sb)
2207
2208
{
@@ -2211,15 +2212,15 @@ diff -u libmagic.orig/magic.c libmagic/magic.c
2211
2212
2212
2213
if ((ms->flags & MAGIC_PRESERVE_ATIME) != 0) {
2213
2214
/*
2214
- @@ -311,7 +313 ,6 @@
2215
+ @@ -311,7 +314 ,6 @@
2215
2216
}
2216
2217
}
2217
2218
2218
2219
- #ifndef COMPILE_ONLY
2219
2220
2220
2221
/*
2221
2222
* find type of descriptor
2222
- @@ -321,7 +322 ,7 @@
2223
+ @@ -321,7 +323 ,7 @@
2223
2224
{
2224
2225
if (ms == NULL)
2225
2226
return NULL;
@@ -2228,7 +2229,7 @@ diff -u libmagic.orig/magic.c libmagic/magic.c
2228
2229
}
2229
2230
2230
2231
/*
2231
- @@ -332,30 +333 ,42 @@
2232
+ @@ -332,30 +334 ,42 @@
2232
2233
{
2233
2234
if (ms == NULL)
2234
2235
return NULL;
@@ -2277,7 +2278,7 @@ diff -u libmagic.orig/magic.c libmagic/magic.c
2277
2278
case -1: /* error */
2278
2279
goto done;
2279
2280
case 0: /* nothing found */
2280
- @@ -365,68 +378 ,48 @@
2281
+ @@ -365,68 +379 ,48 @@
2281
2282
goto done;
2282
2283
}
2283
2284
@@ -2372,7 +2373,7 @@ diff -u libmagic.orig/magic.c libmagic/magic.c
2372
2373
return rv == 0 ? file_getbuffer(ms) : NULL;
2373
2374
}
2374
2375
2375
- @@ -440,14 +433 ,13 @@
2376
+ @@ -440,14 +434 ,13 @@
2376
2377
return NULL;
2377
2378
/*
2378
2379
* The main work is done here!
@@ -2410,25 +2411,26 @@ diff -u libmagic.orig/magic.h libmagic/magic.h
2410
2411
2411
2412
diff -u libmagic.orig/print.c libmagic/print.c
2412
2413
--- libmagic.orig/print.c 2013-03-21 18:45:14.000000000 +0100
2413
- +++ libmagic/print.c 2013-04-08 15:42:57.328298809 +0200
2414
- @@ -28,6 +28,8 @@
2414
+ +++ libmagic/print.c 2013-04-27 13:53:32.175250261 +0200
2415
+ @@ -28,13 +28,17 @@
2415
2416
/*
2416
2417
* print.c - debugging printout routines
2417
2418
*/
2418
2419
+ #define _GNU_SOURCE
2419
2420
+ #include "php.h"
2420
2421
2421
2422
#include "file.h"
2423
+ + #include "cdf.h"
2422
2424
2423
- @@ -35,6 +37,7 @@
2425
+ #ifndef lint
2424
2426
FILE_RCSID("@(#)$File: print.c,v 1.76 2013/02/26 18:25:00 christos Exp $")
2425
2427
#endif /* lint */
2426
2428
2427
2429
+ #include <stdio.h>
2428
2430
#include <string.h>
2429
2431
#include <stdarg.h>
2430
2432
#include <stdlib.h>
2431
- @@ -43,188 +46 ,28 @@
2433
+ @@ -43,188 +47 ,28 @@
2432
2434
#endif
2433
2435
#include <time.h>
2434
2436
@@ -2619,7 +2621,7 @@ diff -u libmagic.orig/print.c libmagic/print.c
2619
2621
- (void) fprintf(stderr, "Warning: ");
2620
2622
va_start(va, f);
2621
2623
- (void) vfprintf(stderr, f, va);
2622
- + vasprintf(&expanded_format, f, va);
2624
+ + if ( vasprintf(&expanded_format, f, va)); /* silence */
2623
2625
va_end(va);
2624
2626
- (void) fputc('\n', stderr);
2625
2627
+
@@ -2629,7 +2631,7 @@ diff -u libmagic.orig/print.c libmagic/print.c
2629
2631
}
2630
2632
2631
2633
protected const char *
2632
- @@ -235,7 +78 ,7 @@
2634
+ @@ -235,7 +79 ,7 @@
2633
2635
struct tm *tm;
2634
2636
2635
2637
if (flags & FILE_T_WINDOWS) {
0 commit comments