diff options
author | John Högberg <[email protected]> | 2017-11-07 07:16:31 +0100 |
---|---|---|
committer | John Högberg <[email protected]> | 2017-11-07 12:44:33 +0100 |
commit | b1ce8325624d22fa34b76407932947a543754962 (patch) | |
tree | 7f77039c13e6c78b665e1f0f9c7039ad461afd6a /erts | |
parent | 3e8c1ff94c0a73df71daadd4eb782c21c49f22d9 (diff) | |
download | otp-b1ce8325624d22fa34b76407932947a543754962.tar.gz otp-b1ce8325624d22fa34b76407932947a543754962.tar.bz2 otp-b1ce8325624d22fa34b76407932947a543754962.zip |
Emasculate writable binaries on entering an iovec
The lack of this caused serious data corruption when a binary was
altered after entering the queue. This went unnoticed because it
was never used without erlang:iolist_to_iovec, which always
emasculates binaries.
Diffstat (limited to 'erts')
-rw-r--r-- | erts/emulator/beam/erl_nif.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/erts/emulator/beam/erl_nif.c b/erts/emulator/beam/erl_nif.c index ac4ecd77e5..8342070521 100644 --- a/erts/emulator/beam/erl_nif.c +++ b/erts/emulator/beam/erl_nif.c @@ -3488,6 +3488,10 @@ static void inspect_raw_binary_data(Eterm binary, ErlNifBinary *result) { if (thing_subtag(*parent_header) == REFC_BINARY_SUBTAG) { ProcBin *pb = (ProcBin*)parent_header; + if (pb->flags & (PB_IS_WRITABLE | PB_ACTIVE_WRITER)) { + erts_emasculate_writable_binary(pb); + } + ASSERT(pb->val != NULL); ASSERT(byte_offset < pb->size); ASSERT(&pb->bytes[byte_offset] >= (byte*)(pb->val)->orig_bytes); |