From 9f779819f6bda734c5953468f77987b73943de35 Mon Sep 17 00:00:00 2001 From: Sverker Eriksson Date: Mon, 20 Jun 2016 17:33:13 +0200 Subject: erts: Fix spawn driver when env size is above pipe capacity Symptom: open_port() succeeds, port program never starts but instead seem to terminate with exit_status 150 (EINVAL+128). When: If the command payload buffer (including the entire environment) for the port program is between 1 to 4 bytes above the pipe capacity, which is 65536 bytes on newer Linux, but can be as low as 4096 on older 32-bit Linux. Since: OTP-19.0-rc1. --- erts/emulator/sys/unix/sys_drivers.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'erts/emulator') diff --git a/erts/emulator/sys/unix/sys_drivers.c b/erts/emulator/sys/unix/sys_drivers.c index ac39b8a389..812112fb91 100644 --- a/erts/emulator/sys/unix/sys_drivers.c +++ b/erts/emulator/sys/unix/sys_drivers.c @@ -762,7 +762,7 @@ static ErlDrvData spawn_start(ErlDrvPort port_num, char* name, } } - if (res < buffsz) { + if (res < (buffsz + sizeof(buffsz))) { /* we only wrote part of the command payload. Enqueue the rest. */ for (i = 0; i < iov_len; i++) { driver_enq(port_num, io_vector[i].iov_base, io_vector[i].iov_len); -- cgit v1.2.3