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-03-31 10:02 UTC

Return to Bug #61566 | Download this patch
This patch is obsolete

Obsoleted by 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

Line 1 (now 1), was 34 lines, now 19 lines

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