aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/beam/erl_bif_re.c
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2011-05-13 14:18:35 +0200
committerBjörn Gustavsson <[email protected]>2011-05-13 14:18:35 +0200
commit0dde47552986f06dc31d43586f6c31d82050f60d (patch)
treef0fffd6302b6b1e64114b8062920ed92bc6ce2b3 /erts/emulator/beam/erl_bif_re.c
parent6f6f9e1a6fd96efd86673855cbdcd316c445c753 (diff)
parent875104fa418b2ead0f19250e75074002ae3e3c72 (diff)
downloadotp-0dde47552986f06dc31d43586f6c31d82050f60d.tar.gz
otp-0dde47552986f06dc31d43586f6c31d82050f60d.tar.bz2
otp-0dde47552986f06dc31d43586f6c31d82050f60d.zip
Merge branch 'bjorn/fix-binary-overflow/OTP-9118' into dev
* bjorn/fix-binary-overflow/OTP-9118: Fix overflow in list_to_bitstring/1 Replace io_list_len() with erts_iolist_size() Make port_command/2 reject non-byte sized bitstrings io.c: Make io_list_vec_len() less general iolist_size/1: Fix truncation of result Test iolist_size/1 with bad arguments binary_SUITE: Remove workaround for avoiding stack overflow
Diffstat (limited to 'erts/emulator/beam/erl_bif_re.c')
-rw-r--r--erts/emulator/beam/erl_bif_re.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/erts/emulator/beam/erl_bif_re.c b/erts/emulator/beam/erl_bif_re.c
index d4a8a3aaa7..26891c4348 100644
--- a/erts/emulator/beam/erl_bif_re.c
+++ b/erts/emulator/beam/erl_bif_re.c
@@ -1,7 +1,7 @@
/*
* %CopyrightBegin%
*
- * Copyright Ericsson AB 2008-2010. All Rights Reserved.
+ * Copyright Ericsson AB 2008-2011. All Rights Reserved.
*
* The contents of this file are subject to the Erlang Public License,
* Version 1.1, (the "License"); you may not use this file except in
@@ -417,7 +417,7 @@ build_compile_result(Process *p, Eterm error_tag, pcre *result, int errcode, con
BIF_RETTYPE
re_compile_2(BIF_ALIST_2)
{
- int slen;
+ Uint slen;
char *expr;
pcre *result;
int errcode = 0;
@@ -444,7 +444,7 @@ re_compile_2(BIF_ALIST_2)
BIF_TRAP2(ucompile_trap_exportp, BIF_P, BIF_ARG_1, BIF_ARG_2);
}
- if ((slen = io_list_len(BIF_ARG_1)) < 0) {
+ if (erts_iolist_size(BIF_ARG_1, &slen)) {
BIF_ERROR(BIF_P,BADARG);
}
expr = erts_alloc(ERTS_ALC_T_RE_TMP_BUF, slen + 1);
@@ -795,8 +795,8 @@ build_capture(Eterm capture_spec[CAPSPEC_SIZE], const pcre *code)
memcpy(tmpb,ap->name,ap->len);
tmpb[ap->len] = '\0';
} else {
- int slen = io_list_len(val);
- if (slen < 0) {
+ Uint slen;
+ if (erts_iolist_size(val, &slen)) {
goto error;
}
if ((slen + 1) > tmpbsiz) {
@@ -851,7 +851,7 @@ re_run_3(BIF_ALIST_3)
const pcre *code_tmp;
RestartContext restart;
byte *temp_alloc = NULL;
- int slength;
+ Uint slength;
int startoffset = 0;
int options = 0, comp_options = 0;
int ovsize;
@@ -875,7 +875,7 @@ re_run_3(BIF_ALIST_3)
if (is_not_tuple(BIF_ARG_2) || (arityval(*tuple_val(BIF_ARG_2)) != 4)) {
if (is_binary(BIF_ARG_2) || is_list(BIF_ARG_2) || is_nil(BIF_ARG_2)) {
/* Compile from textual RE */
- int slen;
+ Uint slen;
char *expr;
pcre *result;
int errcode = 0;
@@ -889,7 +889,7 @@ re_run_3(BIF_ALIST_3)
BIF_TRAP3(urun_trap_exportp, BIF_P, BIF_ARG_1, BIF_ARG_2, BIF_ARG_3);
}
- if ((slen = io_list_len(BIF_ARG_2)) < 0) {
+ if (erts_iolist_size(BIF_ARG_2, &slen)) {
BIF_ERROR(BIF_P,BADARG);
}
@@ -1027,7 +1027,7 @@ re_run_3(BIF_ALIST_3)
restart.flags |= RESTART_FLAG_SUBJECT_IN_BINARY;
} else {
handle_iolist:
- if ((slength = io_list_len(BIF_ARG_1)) < 0) {
+ if (erts_iolist_size(BIF_ARG_1, &slength)) {
erts_free(ERTS_ALC_T_RE_SUBJECT, restart.ovector);
erts_free(ERTS_ALC_T_RE_SUBJECT, restart.code);
if (restart.ret_info != NULL) {