Skip to content

Commit 38ecfe0

Browse files
committed
Merge branch 'PHP-7.4'
* PHP-7.4: Fix #79532: sizeof off_t can be wrong
2 parents 533669f + 67f9b0b commit 38ecfe0

File tree

8 files changed

+52
-0
lines changed

8 files changed

+52
-0
lines changed

build/php.m4

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2418,6 +2418,7 @@ AC_DEFUN([PHP_CHECK_STDINT_TYPES], [
24182418
AC_CHECK_SIZEOF([long])
24192419
AC_CHECK_SIZEOF([long long])
24202420
AC_CHECK_SIZEOF([size_t])
2421+
AC_CHECK_SIZEOF([off_t])
24212422
AC_CHECK_TYPES([int8, int16, int32, int64, int8_t, int16_t, int32_t, int64_t, uint8, uint16, uint32, uint64, uint8_t, uint16_t, uint32_t, uint64_t, u_int8_t, u_int16_t, u_int32_t, u_int64_t], [], [], [
24222423
#include <stdint.h>
24232424
#if HAVE_SYS_TYPES_H

ext/ffi/tests/bug79532.phpt

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
--TEST--
2+
Bug #79532 (sizeof off_t can be wrong)
3+
--SKIPIF--
4+
<?php
5+
if (!extension_loaded('ffi')) die('skip ffi extension not available');
6+
if (!extension_loaded('zend-test')) die('skip zend-test extension not available');
7+
?>
8+
--FILE--
9+
<?php
10+
require_once('utils.inc');
11+
12+
$header = <<<HEADER
13+
void bug79532(off_t *array, size_t elems);
14+
HEADER;
15+
16+
if (PHP_OS_FAMILY !== 'Windows') {
17+
$ffi = FFI::cdef($header);
18+
} else {
19+
try {
20+
$ffi = FFI::cdef($header, 'php_zend_test.dll');
21+
} catch (FFI\Exception $ex) {
22+
$ffi = FFI::cdef($header, ffi_get_php_dll_name());
23+
}
24+
}
25+
26+
$array = FFI::new("off_t[3]");
27+
$ffi->bug79532($array, 3);
28+
var_dump($array);
29+
?>
30+
--EXPECTF--
31+
object(FFI\CData:int%d_t[3])#%d (3) {
32+
[0]=>
33+
int(0)
34+
[1]=>
35+
int(1)
36+
[2]=>
37+
int(2)
38+
}

ext/pdo_pgsql/pdo_pgsql.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include "php_pdo_pgsql_int.h"
2828

2929
#ifdef HAVE_PG_CONFIG_H
30+
#undef SIZEOF_OFF_T
3031
#include <pg_config.h>
3132
#endif
3233

ext/pdo_pgsql/pgsql_driver.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include "pdo/php_pdo_driver.h"
3030
#include "pdo/php_pdo_error.h"
3131
#include "ext/standard/file.h"
32+
#undef SIZEOF_OFF_T
3233
#include "pg_config.h" /* needed for PG_VERSION */
3334
#include "php_pdo_pgsql.h"
3435
#include "php_pdo_pgsql_int.h"

ext/pgsql/php_pgsql.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ extern zend_module_entry pgsql_module_entry;
4949
#endif
5050

5151
#ifdef HAVE_PG_CONFIG_H
52+
#undef SIZEOF_OFF_T
5253
#include <pg_config.h>
5354
#endif
5455

ext/zend_test/php_test.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,6 @@ struct bug79096 {
3636
};
3737

3838
ZEND_API struct bug79096 bug79096(void);
39+
ZEND_API void bug79532(off_t *array, size_t elems);
3940

4041
#endif

ext/zend_test/test.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,3 +328,11 @@ struct bug79096 bug79096(void)
328328
b.b = 1;
329329
return b;
330330
}
331+
332+
void bug79532(off_t *array, size_t elems)
333+
{
334+
int i;
335+
for (i = 0; i < elems; i++) {
336+
array[i] = i;
337+
}
338+
}

win32/build/config.w32.h.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@
9999
# define SIZEOF_SIZE_T 4
100100
# define SIZEOF_PTRDIFF_T 4
101101
#endif
102+
#define SIZEOF_OFF_T 4
102103
#define HAVE_FNMATCH
103104
#define HAVE_GLOB
104105
#define PHP_SHLIB_SUFFIX "dll"

0 commit comments

Comments
 (0)