Skip to content

Commit

Permalink
check max_allowed_stack_size during startup
Browse files Browse the repository at this point in the history
see #237
  • Loading branch information
jcupitt committed Feb 14, 2024
1 parent c686398 commit 81d2281
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,18 @@ server can use it to call any native library they have access to.
Of course if attackers are running their own PHP code on your webserver you
are probably already toast, unfortunately.

Finally, on php 8.3 and later you need to disable stack overflow
tests. php-vips executes FFI callbacks off the main thread and this confuses
those checks, at least in php 8.3.0.

Add:

```
zend.max_allowed_stack_size=-1
```

To your `php.ini`.

### Example

```php
Expand Down
6 changes: 5 additions & 1 deletion src/FFI.php
Original file line number Diff line number Diff line change
Expand Up @@ -236,13 +236,17 @@ private static function init(): void
return;
}

// the two usual installation problems
// detect the most common installation problems
if (!extension_loaded('ffi')) {
throw new Exception('FFI extension not loaded');
}
if (!ini_get('ffi.enable')) {
throw new Exception("ffi.enable not set to 'true'");
}
if (version_compare(PHP_VERSION, '8.3') &&
ini_get('zend.max_allowed_stack_size') != '-1') {
throw new Exception("zend.max_allowed_stack_size not set to '-1'");
}

$vips_libname = self::libraryName("libvips", 42);
if (PHP_OS_FAMILY === "Windows") {
Expand Down

0 comments on commit 81d2281

Please sign in to comment.