Lines Matching refs:magic

5   * apprentice - make one pass through /etc/magic, learning its secrets.
16 #include "magic.h"
69 -private struct magic_map *apprentice_buf(struct magic_set *, struct magic *,
185 - void *b = map->magic[i];
190 - free(map->magic[i]);
195 + if (map->magic[j]) {
196 + efree(map->magic[j]);
240 -/* void **bufs: an array of compiled magic files */
242 -buffer_apprentice(struct magic_set *ms, struct magic **bufs,
284 /* const char *fn: list of magic files and directories */
291 +/* XXX disabling default magic loading so the compiled in data is used */
366 file_error(ms, errno, "cannot read magic file `%s'",
393 - if ((*ma = CAST(struct magic *, malloc(slen))) == NULL) {
394 + if ((*ma = CAST(struct magic *, emalloc(slen))) == NULL) {
516 struct magic *nm;
518 - if ((nm = CAST(struct magic *, realloc(me->mp,
519 + if ((nm = CAST(struct magic *, erealloc(me->mp,
527 - if ((m = CAST(struct magic *, malloc(len))) == NULL) {
528 + if ((m = CAST(struct magic *, emalloc(len))) == NULL) {
603 -apprentice_buf(struct magic_set *ms, struct magic *buf, size_t len)
754 file_error(ms, 0, "bad magic in `%s'", dbname);
764 - file_error(ms, 0, "File %s supports only version %d magic "
766 + file_error(ms, 0, "File %d.%d supports only version %d magic "
772 - entries = CAST(uint32_t, map->len / sizeof(struct magic));
773 - if ((entries * sizeof(struct magic)) != map->len) {
776 - dbname, map->len, sizeof(struct magic));
788 + nentries = (uint32_t)(st.sb.st_size / sizeof(struct magic));
789 + entries = (uint32_t)(st.sb.st_size / sizeof(struct magic));
790 + if ((zend_off_t)(entries * sizeof(struct magic)) != st.sb.st_size) {
793 + sizeof(struct magic));
797 map->magic[0] = CAST(struct magic *, map->p) + 1;
800 map->magic[i + 1] = map->magic[i] + map->nmagic[i];
812 byteswap(map->magic[i], map->nmagic[i]);
835 static const size_t m = sizeof(**map->magic);
841 struct magic m;
873 - if (write(fd, map->magic[i], len) != CAST(ssize_t, len)) {
874 + if (php_stream_write(stream, (const char *)map->magic[i], len) != (ssize_t)len) {
1002 #include "magic.h"
1474 #include "magic.h"
1752 #define MAGIC "/etc/magic"
1850 -protected int buffer_apprentice(struct magic_set *, struct magic **,
1853 protected uint64_t file_signextend(struct magic_set *, struct magic *,
1867 protected void file_mdump(struct magic *);
1877 const struct magic *);
2336 - file_error(ms, 0, "Bad magic format `%s' (%s)", fmt, tbuf);
2666 diff -u libmagic.orig/magic.c libmagic/magic.c
2667 --- libmagic.orig/magic.c 2020-06-15 02:01:01.000000000 +0200
2668 +++ libmagic/magic.c 2021-09-18 21:52:40.223205758 +0200
2682 #include "magic.h"
2763 - "%s/share/misc/magic.mgc",
2764 - "%s/magic.mgc",
2787 - "%s/../share/misc/magic.mgc", dllpath);
2813 - static const char hmagic[] = "/.magic/magic.mgc";
2827 - if (asprintf(&hmagicpath, "%s/.magic.mgc", home) < 0)
2831 - if (asprintf(&hmagicpath, "%s/.magic", home) < 0)
2860 - /* First, try to get a magic file from user-application data */
2864 - /* Second, try to get a magic file from the user profile data */
2869 - /* Third, try to get a magic file from Common Files */
2873 - /* Fourth, try to get magic file relative to exe location */
2876 - /* Fifth, try to get magic file relative to dll location */
2907 - * Install a set of compiled magic buffers.
2915 - return buffer_apprentice(ms, RCAST(struct magic **, bufs),
3142 diff -u libmagic.orig/magic.h libmagic/magic.h
3143 --- libmagic.orig/magic.h 2021-09-18 22:03:56.174790722 +0200
3144 +++ libmagic/magic.h 2021-09-18 21:52:40.227205733 +0200
3353 private int match(struct magic_set *, struct magic *, uint32_t,
3380 struct magic *m = &magic[magindex];
3561 magiccheck(struct magic_set *ms, struct magic *m)