spprintf the dbname
authorMikko Koppanen <mkoppanen@php.net>
Sun, 27 Dec 2009 00:43:33 +0000 (00:43 +0000)
committerMikko Koppanen <mkoppanen@php.net>
Sun, 27 Dec 2009 00:43:33 +0000 (00:43 +0000)
use VCWD_ACCESS instead of access

ext/fileinfo/libmagic/apprentice.c

index 030961aa6193850fe0f08e365ff6c25b77d5b44a..21d8266a09d3b1b121262b94b6ceefa7d5c954ca 100644 (file)
@@ -2120,7 +2120,7 @@ internal_loaded:
        }
 
        if (dbname) {
-               free(dbname);
+               efree(dbname);
        }
        return ret;
 
@@ -2137,7 +2137,7 @@ error1:
        }
 error2:
        if (dbname) {
-               free(dbname);
+               efree(dbname);
        }
        return -1;
 }
@@ -2195,7 +2195,7 @@ apprentice_compile(struct magic_set *ms, struct magic **magicp,
 
        rv = 0;
 out:
-       free(dbname);
+       efree(dbname);
        return rv;
 }
 
@@ -2229,14 +2229,14 @@ mkdbname(struct magic_set *ms, const char *fn, int strip)
        q++;
        /* Compatibility with old code that looked in .mime */
        if (ms->flags & MAGIC_MIME) {
-               asprintf(&buf, "%.*s.mime%s", (int)(q - fn), fn, ext);
-               if (access(buf, R_OK) != -1) {
+               spprintf(&buf, MAXPATHLEN, "%.*s.mime%s", (int)(q - fn), fn, ext);
+               if (VCWD_ACCESS(buf, R_OK) != -1) {
                        ms->flags &= MAGIC_MIME_TYPE;
                        return buf;
                }
-               free(buf);
+               efree(buf);
        }
-       asprintf(&buf, "%.*s%s", (int)(q - fn), fn, ext);
+       spprintf(&buf, MAXPATHLEN, "%.*s%s", (int)(q - fn), fn, ext);
 
        /* Compatibility with old code that looked in .mime */
        if (strstr(p, ".mime") != NULL)