]> granicus.if.org Git - file/commitdiff
always compile file_check_memory as protected.
authorChristos Zoulas <christos@zoulas.com>
Sun, 25 Mar 2007 03:13:47 +0000 (03:13 +0000)
committerChristos Zoulas <christos@zoulas.com>
Sun, 25 Mar 2007 03:13:47 +0000 (03:13 +0000)
src/file.h
src/funcs.c
src/softmagic.c

index cfe0b7f0d8c222d73eae9ee6fa1f47b4d8ccaa33..8d7d5d2ec1fff29dabf372208cae675441dc50a8 100644 (file)
@@ -27,7 +27,7 @@
  */
 /*
  * file.h - definitions for file(1) program
- * @(#)$File: file.h,v 1.89 2007/03/01 22:14:54 christos Exp $
+ * @(#)$File: file.h,v 1.90 2007/03/12 15:43:21 christos Exp $
  */
 
 #ifndef __file_h__
@@ -324,9 +324,7 @@ protected void file_showstr(FILE *, const char *, size_t);
 protected size_t file_mbswidth(const char *);
 protected const char *file_getbuffer(struct magic_set *);
 protected ssize_t sread(int, void *, size_t, int);
-#ifdef ENABLE_CONDITIONALS
 protected int file_check_mem(struct magic_set *, unsigned int);
-#endif
 
 #ifndef COMPILE_ONLY
 extern const char *file_names[];
index d944b1407a71287f5a0e53ce6af30a6a6e390744..95e7dadda3901d073a9ad1cdaa7be00e484c8f78 100644 (file)
@@ -39,7 +39,7 @@
 #endif
 
 #ifndef        lint
-FILE_RCSID("@(#)$File: funcs.c,v 1.27 2007/02/05 16:46:40 christos Exp $")
+FILE_RCSID("@(#)$File: funcs.c,v 1.28 2007/03/01 22:14:54 christos Exp $")
 #endif /* lint */
 
 #ifndef HAVE_VSNPRINTF
@@ -307,6 +307,27 @@ file_getbuffer(struct magic_set *ms)
        return ms->o.pbuf;
 }
 
+protected int
+file_check_mem(struct magic_set *ms, unsigned int level)
+{
+       size_t len;
+
+       if (level >= ms->c.len) {
+               len = (ms->c.len += 20) * sizeof(*ms->c.li);
+               ms->c.li = (ms->c.li == NULL) ? malloc(len) :
+                   realloc(ms->c.li, len);
+               if (ms->c.li == NULL) {
+                       file_oomem(ms, len);
+                       return -1;
+               }
+       }
+       ms->c.li[level].got_match = 0;
+#ifdef ENABLE_CONDITIONALS
+       ms->c.li[level].last_match = 0;
+       ms->c.li[level].last_cond = COND_NONE;
+#endif /* ENABLE_CONDITIONALS */
+       return 0;
+}
 /*
  * Yes these wrappers suffer from buffer overflows, but if your OS does not
  * have the real functions, maybe you should consider replacing your OS?
index b6219c9fab93e2132ea9898609b6688f1f6e7962..1181ab3d91ffadeb741d44721d872e28be113e60 100644 (file)
@@ -38,7 +38,7 @@
 
 
 #ifndef        lint
-FILE_RCSID("@(#)$File: softmagic.c,v 1.95 2007/03/03 19:09:25 christos Exp $")
+FILE_RCSID("@(#)$File: softmagic.c,v 1.96 2007/03/05 02:41:29 christos Exp $")
 #endif /* lint */
 
 private int match(struct magic_set *, struct magic *, uint32_t,
@@ -74,32 +74,6 @@ file_softmagic(struct magic_set *ms, const unsigned char *buf, size_t nbytes)
        return 0;
 }
 
-#ifdef ENABLE_CONDITIONALS
-protected int
-#else
-private int
-#endif
-file_check_mem(struct magic_set *ms, unsigned int level)
-{
-       size_t len;
-
-       if (level >= ms->c.len) {
-               len = (ms->c.len += 20) * sizeof(*ms->c.li);
-               ms->c.li = (ms->c.li == NULL) ? malloc(len) :
-                   realloc(ms->c.li, len);
-               if (ms->c.li == NULL) {
-                       file_oomem(ms, len);
-                       return -1;
-               }
-       }
-       ms->c.li[level].got_match = 0;
-#ifdef ENABLE_CONDITIONALS
-       ms->c.li[level].last_match = 0;
-       ms->c.li[level].last_cond = COND_NONE;
-#endif /* ENABLE_CONDITIONALS */
-       return 0;
-}
-
 /*
  * Go through the whole list, stopping if you find a match.  Process all
  * the continuations of that match before returning.