aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/beam/erl_unicode.c
diff options
context:
space:
mode:
authorRickard Green <[email protected]>2017-10-12 16:28:31 +0200
committerRickard Green <[email protected]>2017-10-12 16:28:31 +0200
commitf28539265d753bbaa473cb488e951bfe47304a01 (patch)
tree86a53f117f1e33b33e57f890f186dbf9b07d8e19 /erts/emulator/beam/erl_unicode.c
parent7dcaed64849f830a44da28c0d49e908d173b173d (diff)
downloadotp-f28539265d753bbaa473cb488e951bfe47304a01.tar.gz
otp-f28539265d753bbaa473cb488e951bfe47304a01.tar.bz2
otp-f28539265d753bbaa473cb488e951bfe47304a01.zip
Revert "Merge branch 'rickard/null-char-filenames/ERL-370/OTP-14543' into maint"
This reverts commit 0717a2194e863f3a78595184ccc5637697f03353, reversing changes made to 71a40658a0cef8b3e25df3a8e48a72d0563a89bf.
Diffstat (limited to 'erts/emulator/beam/erl_unicode.c')
-rw-r--r--erts/emulator/beam/erl_unicode.c58
1 files changed, 5 insertions, 53 deletions
diff --git a/erts/emulator/beam/erl_unicode.c b/erts/emulator/beam/erl_unicode.c
index efd2ca3db2..2d1d1443a7 100644
--- a/erts/emulator/beam/erl_unicode.c
+++ b/erts/emulator/beam/erl_unicode.c
@@ -1988,7 +1988,7 @@ char *erts_convert_filename_to_encoding(Eterm name, char *statbuf, size_t statbu
is_list(name) ||
(allow_empty && is_nil(name))) {
Sint need;
- if ((need = erts_native_filename_need(name, encoding, 0)) < 0) {
+ if ((need = erts_native_filename_need(name,encoding)) < 0) {
return NULL;
}
if (encoding == ERL_FILENAME_WIN_WCHAR) {
@@ -2152,13 +2152,12 @@ Eterm erts_convert_native_to_filename(Process *p, byte *bytes)
}
-Sint erts_native_filename_need(Eterm ioterm, int encoding, int allow_null)
+Sint erts_native_filename_need(Eterm ioterm, int encoding)
{
Eterm *objp;
Eterm obj;
DECLARE_ESTACK(stack);
Sint need = 0;
- int seen_null = 0;
if (is_atom(ioterm)) {
Atom* ap;
@@ -2195,24 +2194,6 @@ Sint erts_native_filename_need(Eterm ioterm, int encoding, int allow_null)
default:
need = -1;
}
- if (!allow_null) {
- /*
- * Do not allow null in
- * the middle of filenames
- */
- if (need > 0) {
- byte *name = ap->name;
- int len = ap->len;
- for (i = 0; i < len; i++) {
- if (name[i] == 0)
- seen_null = 1;
- else if (seen_null) {
- need = -1;
- break;
- }
- }
- }
- }
DESTROY_ESTACK(stack);
return need;
}
@@ -2243,18 +2224,6 @@ L_Again: /* Restart with sublist, old listend was pushed on stack */
if (is_small(obj)) { /* Always small */
for(;;) {
Uint x = unsigned_val(obj);
- if (!allow_null) {
- /*
- * Do not allow null in
- * the middle of filenames
- */
- if (x == 0)
- seen_null = 1;
- else if (seen_null) {
- DESTROY_ESTACK(stack);
- return ((Sint) -1);
- }
- }
switch (encoding) {
case ERL_FILENAME_LATIN1:
if (x > 255) {
@@ -2546,7 +2515,6 @@ BIF_RETTYPE prim_file_internal_name2native_1(BIF_ALIST_1)
BIF_ERROR(BIF_P,BADARG);
}
if (is_binary(BIF_ARG_1)) {
- int seen_null = 0;
byte *temp_alloc = NULL;
byte *bytes;
byte *err_pos;
@@ -2556,18 +2524,10 @@ BIF_RETTYPE prim_file_internal_name2native_1(BIF_ALIST_1)
size = binary_size(BIF_ARG_1);
bytes = erts_get_aligned_binary_bytes(BIF_ARG_1, &temp_alloc);
if (encoding != ERL_FILENAME_WIN_WCHAR) {
- Uint i;
/*Add 0 termination only*/
bin_term = new_binary(BIF_P, NULL, size+1);
bin_p = binary_bytes(bin_term);
- for (i = 0; i < size; i++) {
- /* Don't allow null in the middle of filenames... */
- if (bytes[i] == 0)
- seen_null = 1;
- else if (seen_null)
- goto bin_name_error;
- bin_p[i] = bytes[i];
- }
+ memcpy(bin_p,bytes,size);
bin_p[size]=0;
erts_free_aligned_binary_bytes(temp_alloc);
BIF_RET(bin_term);
@@ -2581,11 +2541,6 @@ BIF_RETTYPE prim_file_internal_name2native_1(BIF_ALIST_1)
bin_term = new_binary(BIF_P, 0, (size+1)*2);
bin_p = binary_bytes(bin_term);
while (size--) {
- /* Don't allow null in the middle of filenames... */
- if (*bytes == 0)
- seen_null = 1;
- else if (seen_null)
- goto bin_name_error;
*bin_p++ = *bytes++;
*bin_p++ = 0;
}
@@ -2603,14 +2558,11 @@ BIF_RETTYPE prim_file_internal_name2native_1(BIF_ALIST_1)
bin_p[num_chars*2+1] = 0;
erts_free_aligned_binary_bytes(temp_alloc);
BIF_RET(bin_term);
- bin_name_error:
- erts_free_aligned_binary_bytes(temp_alloc);
- BIF_ERROR(BIF_P,BADARG);
} /* binary */
- if ((need = erts_native_filename_need(BIF_ARG_1, encoding, 0)) < 0) {
- BIF_ERROR(BIF_P,BADARG);
+ if ((need = erts_native_filename_need(BIF_ARG_1,encoding)) < 0) {
+ BIF_ERROR(BIF_P,BADARG);
}
if (encoding == ERL_FILENAME_WIN_WCHAR) {
need += 2;