php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Return to Bug #61566
Patch 61566.diff revision 2012-04-02 15:07 UTC by ab@php.net
revision 2012-04-02 12:58 UTC by ab@php.net
revision 2012-03-31 10:02 UTC by ab@php.net

Patch 61566.diff for *Directory/Filesystem functions Bug #61566

Patch version 2012-04-02 12:58 UTC

Return to Bug #61566 | Download this patch
This patch renders other patches obsolete

Obsolete patches:

Patch Revisions: 2012-04-02 15:07 UTC | 2012-04-02 12:58 UTC | 2012-03-31 10:02 UTC

Developer: ab@php.net



  diff --git a/ext/fileinfo/libmagic/cdf.c b/ext/fileinfo/libmagic/cdf.c
 index 1f0f63b..849375e 100644
 index 1f0f63b..7efa43e 100644
  --- a/ext/fileinfo/libmagic/cdf.c
  +++ b/ext/fileinfo/libmagic/cdf.c
 @@ -298,7 +298,14 @@ cdf_read(const cdf_info_t *info, off_t off, void *buf, size_t len)
 @@ -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 PHP_API_VERSION < 20100412 && defined PHP_WIN32
 +	if (info->i_buf != NULL) {
 +		if (info->i_len < siz) {
 +			len = info->i_len;
 +		}
 -	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/file.h b/ext/fileinfo/libmagic/file.h
 index b73c9b1..e1269ae 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
  	if (info->i_buf != NULL && info->i_len >= siz) {
 +#define FINFO_LSEEK_FUNC lseek
 +#define FINFO_READ_FUNC read
  +#endif
  		(void)memcpy(buf, &info->i_buf[off], len);
  		return (ssize_t)len;
  	}
 +
  #endif /* __file_h__ */
 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Sun Apr 20 03:02:42 2014 UTC