Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,23 +36,21 @@ Or macOS:
brew install vips
```

You'll need to [enable FFI in your
PHP](https://www.php.net/manual/en/ffi.configuration.php), then add vips
to your `composer.json`:
php-vips does not yet support FFI preloading, so you need to enable FFI globally by setting `ffi.enable` to `true`. This has some security implications, since anyone who can run php on your 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.

For more information see the [FFI Runtime Configuration](https://www.php.net/manual/en/ffi.configuration.php).

Then add vips to your `composer.json`:

```
"require": {
"jcupitt/vips" : "2.4.0"
}
```

php-vips does not yet support preloading, so you need to enable FFI globally.
This has some security implications, since anyone who can run php on your
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.
Expand Down
3 changes: 3 additions & 0 deletions src/FFI.php
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,9 @@ private static function init(): void
}
$msg .= ". Make sure that you've installed libvips and that '$vips_libname'";
$msg .= " is on your system's library search path.";
if ('preload' === ini_get('ffi.enable')) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about moving this up a bit? On line 284 we have:

        if (!ini_get('ffi.enable')) {
            throw new Exception("ffi.enable not set to 'true'");
        }

We could change that to:

        if (!ini_get('ffi.enable') ||
            ini_get('ffi.enable') === 'preload') {
            throw new Exception("ffi.enable not set to 'true'");
        }

I think (I think??) we need both tests.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That’s probably a better place for it, I just worry about unintended consequences. I don’t know enough about FFI to fully grasp what this might mean later on down the line.

$msg .= "FFI is not enabled globally; this will prevent PHP from locating '$vips_libname'.";
}
throw new Exception($msg);
}

Expand Down