]> granicus.if.org Git - file/commitdiff
PR/466: Windows fixes.
authorChristos Zoulas <christos@zoulas.com>
Sat, 11 Jul 2015 14:41:37 +0000 (14:41 +0000)
committerChristos Zoulas <christos@zoulas.com>
Sat, 11 Jul 2015 14:41:37 +0000 (14:41 +0000)
ChangeLog
src/file.h
src/gmtime_r.c
src/localtime_r.c
src/magic.c
src/readelf.c

index 1fb44a26be89ebe8f5321c1512716b03c6fb6f95..3c0be5e9f10ca979b4cd5c1370bb0f9816250a68 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2015-07-11  10:35  Christos Zoulas <christos@zoulas.com>
+
+       * Windows fixes PR/466 (Jason Hood)
+
 2015-07-09  10:35  Christos Zoulas <christos@zoulas.com>
 
        * release 5.24
index 1b4ef6f7a2cc800b4d2ecb35289827b975cc6c0f..2ad2f97eb390e778437a5dd6257e94efb8869f7c 100644 (file)
@@ -27,7 +27,7 @@
  */
 /*
  * file.h - definitions for file(1) program
- * @(#)$File: file.h,v 1.168 2015/04/09 20:01:41 christos Exp $
+ * @(#)$File: file.h,v 1.169 2015/07/11 14:41:37 christos Exp $
  */
 
 #ifndef __file_h__
     #define SIZE_T_FORMAT ""
   #endif
   #define INT64_T_FORMAT "I64"
+  #define INTMAX_T_FORMAT "I64"
 #else
   #define SIZE_T_FORMAT "z"
   #define INT64_T_FORMAT "ll"
+  #define INTMAX_T_FORMAT "j"
 #endif
 
 #include <stdio.h>     /* Include that here, to make sure __P gets defined */
index 963dfeefca19a06175daf08e41ab04b32efdff2e..469ec650a5fe7f4e81d5c0be7176a7da24c41586 100644 (file)
@@ -1,15 +1,15 @@
-/*     $File: gmtime_r.c,v 1.1 2015/01/09 19:28:32 christos Exp $      */
+/*     $File: gmtime_r.c,v 1.2 2015/07/11 14:41:37 christos Exp $      */
 
 #include "file.h"
 #ifndef        lint
-FILE_RCSID("@(#)$File: gmtime_r.c,v 1.1 2015/01/09 19:28:32 christos Exp $")
+FILE_RCSID("@(#)$File: gmtime_r.c,v 1.2 2015/07/11 14:41:37 christos Exp $")
 #endif /* lint */
 #include <time.h>
 #include <string.h>
 
 /* asctime_r is not thread-safe anyway */
 struct tm *
-gmtime_r(const time_t t, struct tm *tm)
+gmtime_r(const time_t *t, struct tm *tm)
 {
        struct tm *tmp = gmtime(t);
        if (tmp == NULL)
index 69d78d9a84ef96ad935286adf869d7f6cbe3b7f9..b0d996dafa5faaf5b6b5cbf4d4eb6b7fddf898a5 100644 (file)
@@ -1,15 +1,15 @@
-/*     $File: localtime_r.c,v 1.1 2015/01/09 19:28:32 christos Exp $   */
+/*     $File: localtime_r.c,v 1.2 2015/07/11 14:41:37 christos Exp $   */
 
 #include "file.h"
 #ifndef        lint
-FILE_RCSID("@(#)$File: localtime_r.c,v 1.1 2015/01/09 19:28:32 christos Exp $")
+FILE_RCSID("@(#)$File: localtime_r.c,v 1.2 2015/07/11 14:41:37 christos Exp $")
 #endif /* lint */
 #include <time.h>
 #include <string.h>
 
 /* asctime_r is not thread-safe anyway */
 struct tm *
-localtime_r(const time_t t, struct tm *tm)
+localtime_r(const time_t *t, struct tm *tm)
 {
        struct tm *tmp = localtime(t);
        if (tmp == NULL)
index bc8c344b18d0b2864902cd39af98908799c70348..9a1c56dde304b5bc7dccc9a07fcbfae04005d0ef 100644 (file)
@@ -33,7 +33,7 @@
 #include "file.h"
 
 #ifndef        lint
-FILE_RCSID("@(#)$File: magic.c,v 1.93 2015/04/15 23:47:58 christos Exp $")
+FILE_RCSID("@(#)$File: magic.c,v 1.94 2015/07/11 14:41:37 christos Exp $")
 #endif /* lint */
 
 #include "magic.h"
@@ -137,6 +137,14 @@ _w32_get_magic_relative_to(char **hmagicpath, HINSTANCE module)
 
        PathRemoveFileSpecA(dllpath);
 
+       if (module) {
+               char exepath[MAX_PATH];
+               GetModuleFileNameA(NULL, exepath, MAX_PATH);
+               PathRemoveFileSpecA(exepath);
+               if (stricmp(exepath, dllpath) == 0)
+                       goto out;
+       }
+
        sp = strlen(dllpath);
        if (sp > 3 && stricmp(&dllpath[sp - 3], "bin") == 0) {
                _w32_append_path(hmagicpath,
index bc6e7f6b42e45062c737114ace73495cef019ee4..957be0316f7934497dc4450100aa710c48ccba1f 100644 (file)
@@ -27,7 +27,7 @@
 #include "file.h"
 
 #ifndef lint
-FILE_RCSID("@(#)$File: readelf.c,v 1.120 2015/06/16 14:18:07 christos Exp $")
+FILE_RCSID("@(#)$File: readelf.c,v 1.121 2015/07/11 14:41:37 christos Exp $")
 #endif
 
 #ifdef BUILTIN_ELF
@@ -1054,9 +1054,11 @@ doshn(struct magic_set *ms, int clazz, int swap, int fd, off_t off, int num,
                case SHT_NOTE:
                        if (xsh_size + xsh_offset > (uintmax_t)fsize)  {
                                if (file_printf(ms,
-                                   ", note offset/size 0x%jx+0x%jx exceeds"
-                                   " file size 0x%jx", (uintmax_t)xsh_offset,
-                                   (uintmax_t)xsh_size, (uintmax_t)fsize) == -1)
+                                   ", note offset/size 0x%" INTMAX_T_FORMAT
+                                   "x+0x%" INTMAX_T_FORMAT "x exceeds"
+                                   " file size 0x%" INTMAX_T_FORMAT "x",
+                                   (uintmax_t)xsh_offset, (uintmax_t)xsh_size,
+                                   (uintmax_t)fsize) == -1)
                                        return -1;
                                return 0; 
                        }
@@ -1065,7 +1067,8 @@ doshn(struct magic_set *ms, int clazz, int swap, int fd, off_t off, int num,
                                    " for note");
                                return -1;
                        }
-                       if (pread(fd, nbuf, xsh_size, xsh_offset) < (ssize_t)xsh_size) {
+                       if (pread(fd, nbuf, xsh_size, xsh_offset) <
+                           (ssize_t)xsh_size) {
                                file_badread(ms);
                                free(nbuf);
                                return -1;