Tags: patch

I made two patches which resolve the problem for me, one fixes
magic_compile(), the other one magic_check():

--- src/magic.c.orig    2006-12-15 14:12:38.000000000 +0100
+++ src/magic.c 2006-12-15 14:14:28.000000000 +0100
@@ -86,6 +86,7 @@
 
        if ((ms = malloc(sizeof(struct magic_set))) == NULL)
                return NULL;
+       memset(ms, 0, sizeof(*ms));
 
        if (magic_setflags(ms, flags) == -1) {
                errno = EINVAL;

--- src/apprentice.c.orig       2006-12-15 14:02:54.000000000 +0100
+++ src/apprentice.c    2006-12-15 14:03:40.000000000 +0100
@@ -381,7 +381,7 @@
        }
 
         maxmagic = MAXMAGIS;
-       if ((marray = malloc(maxmagic * sizeof(*marray))) == NULL) {
+       if ((marray = calloc(maxmagic, sizeof(*marray))) == NULL) {
                (void)fclose(f);
                file_oomem(ms);
                return -1;

All the problems are missing initializations, there can be many more of
these bugs in the code :(. Is somebody maintaining file/libmagic (despite
the Debian package)?

Markus

-- 
BOFH excuse #452: Rhythmic variations in the voltage reaching the power supply.


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to