diff options
author | Ondřej Surý <ondrej@sury.org> | 2012-04-13 14:53:37 +0200 |
---|---|---|
committer | Ondřej Surý <ondrej@sury.org> | 2012-04-13 14:53:37 +0200 |
commit | e0dcba421c579b36da678d886e1673be84225ae8 (patch) | |
tree | ccba89ef21e71cadedce7ec14d18f67e08ea0882 /ext/fileinfo/libmagic | |
parent | 7b10b0041aa63c6f8990ceb3ccc190bdd9eea2b9 (diff) | |
download | php-e0dcba421c579b36da678d886e1673be84225ae8.tar.gz |
Imported Upstream version 5.4.1~rc2upstream/5.4.1_rc2
Diffstat (limited to 'ext/fileinfo/libmagic')
-rw-r--r-- | ext/fileinfo/libmagic/cdf.c | 4 | ||||
-rw-r--r-- | ext/fileinfo/libmagic/compress.c | 6 | ||||
-rw-r--r-- | ext/fileinfo/libmagic/file.h | 8 | ||||
-rw-r--r-- | ext/fileinfo/libmagic/readelf.c | 30 |
4 files changed, 28 insertions, 20 deletions
diff --git a/ext/fileinfo/libmagic/cdf.c b/ext/fileinfo/libmagic/cdf.c index 1f0f63b69..7efa43e00 100644 --- a/ext/fileinfo/libmagic/cdf.c +++ b/ext/fileinfo/libmagic/cdf.c @@ -306,10 +306,10 @@ cdf_read(const cdf_info_t *info, off_t off, void *buf, size_t len) if (info->i_fd == -1) return -1; - if (lseek(info->i_fd, off, SEEK_SET) == (off_t)-1) + if (FINFO_LSEEK_FUNC(info->i_fd, off, SEEK_SET) == (off_t)-1) return -1; - if (read(info->i_fd, buf, len) != (ssize_t)len) + if (FINFO_READ_FUNC(info->i_fd, buf, len) != (ssize_t)len) return -1; return (ssize_t)len; diff --git a/ext/fileinfo/libmagic/compress.c b/ext/fileinfo/libmagic/compress.c index c31f0f8b8..4d349cd41 100644 --- a/ext/fileinfo/libmagic/compress.c +++ b/ext/fileinfo/libmagic/compress.c @@ -224,7 +224,7 @@ sread(int fd, void *buf, size_t n, int canbepipe) nocheck: do - switch ((rv = read(fd, buf, n))) { + switch ((rv = FINFO_READ_FUNC(fd, buf, n))) { case -1: if (errno == EINTR) continue; @@ -301,7 +301,7 @@ file_pipe2file(struct magic_set *ms, int fd, const void *startbuf, return -1; } (void)close(tfd); - if (lseek(fd, (off_t)0, SEEK_SET) == (off_t)-1) { + if (FINFO_LSEEK_FUNC(fd, (off_t)0, SEEK_SET) == (off_t)-1) { file_badseek(ms); return -1; } @@ -405,7 +405,7 @@ uncompressbuf(struct magic_set *ms, int fd, size_t method, (void) close(0); if (fd != -1) { (void) dup(fd); - (void) lseek(0, (off_t)0, SEEK_SET); + (void) FINFO_LSEEK_FUNC(0, (off_t)0, SEEK_SET); } else { (void) dup(fdin[0]); (void) close(fdin[0]); diff --git a/ext/fileinfo/libmagic/file.h b/ext/fileinfo/libmagic/file.h index b73c9b1c1..e1269aee0 100644 --- a/ext/fileinfo/libmagic/file.h +++ b/ext/fileinfo/libmagic/file.h @@ -486,4 +486,12 @@ static const char *rcsid(const char *p) { \ #define FILE_RCSID(id) #endif +#ifdef PHP_WIN32 +#define FINFO_LSEEK_FUNC _lseek +#define FINFO_READ_FUNC _read +#else +#define FINFO_LSEEK_FUNC lseek +#define FINFO_READ_FUNC read +#endif + #endif /* __file_h__ */ diff --git a/ext/fileinfo/libmagic/readelf.c b/ext/fileinfo/libmagic/readelf.c index 7e768ca7b..f18f7d229 100644 --- a/ext/fileinfo/libmagic/readelf.c +++ b/ext/fileinfo/libmagic/readelf.c @@ -309,11 +309,11 @@ dophn_core(struct magic_set *ms, int clazz, int swap, int fd, off_t off, * Loop through all the program headers. */ for ( ; num; num--) { - if (lseek(fd, off, SEEK_SET) == (off_t)-1) { + if (FINFO_LSEEK_FUNC(fd, off, SEEK_SET) == (off_t)-1) { file_badseek(ms); return -1; } - if (read(fd, xph_addr, xph_sizeof) == -1) { + if (FINFO_READ_FUNC(fd, xph_addr, xph_sizeof) == -1) { file_badread(ms); return -1; } @@ -331,11 +331,11 @@ dophn_core(struct magic_set *ms, int clazz, int swap, int fd, off_t off, * This is a PT_NOTE section; loop through all the notes * in the section. */ - if (lseek(fd, xph_offset, SEEK_SET) == (off_t)-1) { + if (FINFO_LSEEK_FUNC(fd, xph_offset, SEEK_SET) == (off_t)-1) { file_badseek(ms); return -1; } - bufsize = read(fd, nbuf, + bufsize = FINFO_READ_FUNC(fd, nbuf, ((xph_filesz < sizeof(nbuf)) ? xph_filesz : sizeof(nbuf))); if (bufsize == -1) { file_badread(ms); @@ -858,11 +858,11 @@ doshn(struct magic_set *ms, int clazz, int swap, int fd, off_t off, int num, } for ( ; num; num--) { - if (lseek(fd, off, SEEK_SET) == (off_t)-1) { + if (FINFO_LSEEK_FUNC(fd, off, SEEK_SET) == (off_t)-1) { file_badseek(ms); return -1; } - if (read(fd, xsh_addr, xsh_sizeof) == -1) { + if (FINFO_READ_FUNC(fd, xsh_addr, xsh_sizeof) == -1) { file_badread(ms); return -1; } @@ -888,13 +888,13 @@ doshn(struct magic_set *ms, int clazz, int swap, int fd, off_t off, int num, switch (xsh_type) { case SHT_NOTE: nbuf = emalloc((size_t)xsh_size); - if ((noff = lseek(fd, (off_t)xsh_offset, SEEK_SET)) == + if ((noff = FINFO_LSEEK_FUNC(fd, (off_t)xsh_offset, SEEK_SET)) == (off_t)-1) { file_badread(ms); efree(nbuf); return -1; } - if (read(fd, nbuf, (size_t)xsh_size) != + if (FINFO_READ_FUNC(fd, nbuf, (size_t)xsh_size) != (ssize_t)xsh_size) { efree(nbuf); file_badread(ms); @@ -914,7 +914,7 @@ doshn(struct magic_set *ms, int clazz, int swap, int fd, off_t off, int num, efree(nbuf); break; case SHT_SUNW_cap: - if (lseek(fd, (off_t)xsh_offset, SEEK_SET) == + if (FINFO_LSEEK_FUNC(fd, (off_t)xsh_offset, SEEK_SET) == (off_t)-1) { file_badseek(ms); return -1; @@ -927,7 +927,7 @@ doshn(struct magic_set *ms, int clazz, int swap, int fd, off_t off, int num, MAX(sizeof cap32, sizeof cap64)]; if ((coff += xcap_sizeof) > (off_t)xsh_size) break; - if (read(fd, cbuf, (size_t)xcap_sizeof) != + if (FINFO_READ_FUNC(fd, cbuf, (size_t)xcap_sizeof) != (ssize_t)xcap_sizeof) { file_badread(ms); return -1; @@ -1046,12 +1046,12 @@ dophn_exec(struct magic_set *ms, int clazz, int swap, int fd, off_t off, } for ( ; num; num--) { - if (lseek(fd, off, SEEK_SET) == (off_t)-1) { + if (FINFO_LSEEK_FUNC(fd, off, SEEK_SET) == (off_t)-1) { file_badseek(ms); return -1; } - if (read(fd, xph_addr, xph_sizeof) == -1) { + if (FINFO_READ_FUNC(fd, xph_addr, xph_sizeof) == -1) { file_badread(ms); return -1; } @@ -1090,11 +1090,11 @@ dophn_exec(struct magic_set *ms, int clazz, int swap, int fd, off_t off, * This is a PT_NOTE section; loop through all the notes * in the section. */ - if (lseek(fd, xph_offset, SEEK_SET) == (off_t)-1) { + if (FINFO_LSEEK_FUNC(fd, xph_offset, SEEK_SET) == (off_t)-1) { file_badseek(ms); return -1; } - bufsize = read(fd, nbuf, ((xph_filesz < sizeof(nbuf)) ? + bufsize = FINFO_READ_FUNC(fd, nbuf, ((xph_filesz < sizeof(nbuf)) ? xph_filesz : sizeof(nbuf))); if (bufsize == -1) { file_badread(ms); @@ -1156,7 +1156,7 @@ file_tryelf(struct magic_set *ms, int fd, const unsigned char *buf, /* * If we cannot seek, it must be a pipe, socket or fifo. */ - if((lseek(fd, (off_t)0, SEEK_SET) == (off_t)-1) && (errno == ESPIPE)) + if((FINFO_LSEEK_FUNC(fd, (off_t)0, SEEK_SET) == (off_t)-1) && (errno == ESPIPE)) fd = file_pipe2file(ms, fd, buf, nbytes); if (fstat(fd, &st) == -1) { |