File 0263-badarg-on-iolist_to_binary-Bitstring.patch of Package erlang

From 443fbb24248516523512c9bc591252eafafd1311 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?John=20H=C3=B6gberg?= <john@erlang.org>
Date: Thu, 15 Feb 2018 17:06:36 +0100
Subject: [PATCH 2/2] badarg on iolist_to_binary(Bitstring)

When supplied without an enclosing list, bitstrings were returned
as-is instead of badarging.
---
 erts/emulator/beam/binary.c         | 5 ++++-
 erts/emulator/test/binary_SUITE.erl | 1 +
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/erts/emulator/beam/binary.c b/erts/emulator/beam/binary.c
index ca3e48e205..cf7dcb13d5 100644
--- a/erts/emulator/beam/binary.c
+++ b/erts/emulator/beam/binary.c
@@ -964,7 +964,10 @@ HIPE_WRAPPER_BIF_DISABLE_GC(iolist_to_binary, 1)
 BIF_RETTYPE iolist_to_binary_1(BIF_ALIST_1)
 {
     if (is_binary(BIF_ARG_1)) {
-	BIF_RET(BIF_ARG_1);
+        if (binary_bitsize(BIF_ARG_1) == 0) {
+            BIF_RET(BIF_ARG_1);
+        }
+        BIF_ERROR(BIF_P, BADARG);
     }
     return erts_list_to_binary_bif(BIF_P, BIF_ARG_1, bif_export[BIF_iolist_to_binary_1]);
 }
diff --git a/erts/emulator/test/binary_SUITE.erl b/erts/emulator/test/binary_SUITE.erl
index 61536bacd7..374f91e487 100644
--- a/erts/emulator/test/binary_SUITE.erl
+++ b/erts/emulator/test/binary_SUITE.erl
@@ -257,6 +257,7 @@ test_deep_bitstr(List) ->
     {Bin,bitstring_to_list(Bin)}.
 
 bad_list_to_binary(Config) when is_list(Config) ->
+    test_bad_bin(<<1:1>>),
     test_bad_bin(atom),
     test_bad_bin(42),
     test_bad_bin([1|2]),
-- 
2.16.2

openSUSE Build Service is sponsored by