aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSverker Eriksson <[email protected]>2016-06-20 17:33:13 +0200
committerSverker Eriksson <[email protected]>2016-06-20 18:50:02 +0200
commit9f779819f6bda734c5953468f77987b73943de35 (patch)
tree8d7f71e6a482de7a28ace8b9101ce509b618c7cc
parentf91576820fd84c08fd2d3c9675b7801738740d4a (diff)
downloadotp-9f779819f6bda734c5953468f77987b73943de35.tar.gz
otp-9f779819f6bda734c5953468f77987b73943de35.tar.bz2
otp-9f779819f6bda734c5953468f77987b73943de35.zip
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.
-rw-r--r--erts/emulator/sys/unix/sys_drivers.c2
1 files changed, 1 insertions, 1 deletions
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);