com php-src: catching up: ext/fileinfo/libmagic/apprentice.c ext/fileinfo/libmagic/magic.c

From: Date: Sun, 08 Mar 2015 18:47:30 +0000
Subject: com php-src: catching up: ext/fileinfo/libmagic/apprentice.c ext/fileinfo/libmagic/magic.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-85339@lists.php.net to get a copy of this message
Commit: 5892ec175aadb90e19abf84fe08eae4ce3262718 Author: Anatol Belski <ab@php.net> Fri, 6 Mar 2015 16:52:14 +0100 Parents: ca98547801d06fed7b3c7ea15028c25326828cfa Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=5892ec175aadb90e19abf84fe08eae4ce3262718 Log: catching up Changed paths: M ext/fileinfo/libmagic/apprentice.c M ext/fileinfo/libmagic/magic.c Diff: diff --git a/ext/fileinfo/libmagic/apprentice.c b/ext/fileinfo/libmagic/apprentice.c index 5647089..2ecf6c6 100644 --- a/ext/fileinfo/libmagic/apprentice.c +++ b/ext/fileinfo/libmagic/apprentice.c @@ -2944,10 +2944,6 @@ error: return NULL; } -private const uint32_t ar[] = { - MAGICNO, VERSIONNO -}; - private int check_buffer(struct magic_set *ms, struct magic_map *map, const char *dbname) { @@ -3017,6 +3013,10 @@ apprentice_compile(struct magic_set *ms, struct magic_map *map, const char *fn) char *dbname; int rv = -1; uint32_t i; + union { + struct magic m; + uint32_t h[2 + MAGIC_SETS]; + } hdr; php_stream *stream; @@ -3032,24 +3032,16 @@ apprentice_compile(struct magic_set *ms, struct magic_map *map, const char *fn) file_error(ms, errno, "cannot open `%s'", dbname); goto out; } + memset(&hdr, 0, sizeof(hdr)); + hdr.h[0] = MAGICNO; + hdr.h[1] = VERSIONNO; + memcpy(hdr.h + 2, map->nmagic, nm); - if (write(fd, ar, sizeof(ar)) != (ssize_t)sizeof(ar)) { - file_error(ms, errno, "error writing `%s'", dbname); - goto out; - } - - if (php_stream_write(stream, (const char *)map->nmagic, nm) != (ssize_t)nm) { + if (php_stream_write(stream,(const char *)&hdr, sizeof(hdr)) != (ssize_t)sizeof(hdr)) { file_error(ms, errno, "error writing `%s'", dbname); goto out; } - assert(nm + sizeof(ar) < m); - - if (php_stream_seek(stream,(zend_off_t)sizeof(struct magic), SEEK_SET) != sizeof(struct magic)) { - file_error(ms, errno, "error seeking `%s'", dbname); - goto out; - } - for (i = 0; i < MAGIC_SETS; i++) { len = m * map->nmagic[i]; if (php_stream_write(stream, (const char *)map->magic[i], len) != (ssize_t)len) { @@ -3061,7 +3053,6 @@ apprentice_compile(struct magic_set *ms, struct magic_map *map, const char *fn) if (stream) { php_stream_close(stream); } - rv = 0; out: efree(dbname); diff --git a/ext/fileinfo/libmagic/magic.c b/ext/fileinfo/libmagic/magic.c index 28edb8a..380cb72 100644 --- a/ext/fileinfo/libmagic/magic.c +++ b/ext/fileinfo/libmagic/magic.c @@ -269,18 +269,6 @@ magic_load(struct magic_set *ms, const char *magicfile) return file_apprentice(ms, magicfile, FILE_LOAD); } -/* - * Install a set of compiled magic buffers. - */ -public int -magic_load_buffers(struct magic_set *ms, void **bufs, size_t *sizes, - size_t nbufs) -{ - if (ms == NULL) - return -1; - return buffer_apprentice(ms, (struct magic **)bufs, sizes, nbufs); -} - public int magic_compile(struct magic_set *ms, const char *magicfile) {

« previous php.cvs (#85339) next »