From f76bddd36de9c881837dfb76c3edf913a566802c Mon Sep 17 00:00:00 2001 From: Micael Karlberg Date: Mon, 25 Mar 2013 18:13:37 +0100 Subject: Calculation of term_spec size (initial and next) changed There seem to be some problem with realloc (core dump) so the calculation of the term_spec size needs to be "corrected". --- .../src/flex/megaco_flex_scanner_drv.flex.src | 27 +++++++++++++++++----- 1 file changed, 21 insertions(+), 6 deletions(-) (limited to 'lib/megaco/src/flex') diff --git a/lib/megaco/src/flex/megaco_flex_scanner_drv.flex.src b/lib/megaco/src/flex/megaco_flex_scanner_drv.flex.src index b96a69415d..a8ff86e528 100644 --- a/lib/megaco/src/flex/megaco_flex_scanner_drv.flex.src +++ b/lib/megaco/src/flex/megaco_flex_scanner_drv.flex.src @@ -1,7 +1,7 @@ /* * %CopyrightBegin% * - * Copyright Ericsson AB 2001-2009. All Rights Reserved. + * Copyright Ericsson AB 2001-2013. 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 @@ -101,6 +101,13 @@ typedef struct { int token_counter; } MfsErlDrvData; +/* IBL = In Buffer Length - the raw (un-decoded) message buffer length */ +#define TERM_SPEC_SIZE_INITIAL(IBL) (1024 + 2*(IBL)) + +/* CTSS = Current term spec size - the current term spec length */ +/* S = Size - how many positions we need */ +#define TERM_SPEC_SIZE_NEXT(CTSS,S) ((CTSS) + 1024 + (S)) + #if !defined(MEGACO_REENTRANT_FLEX_SCANNER) static MfsErlDrvData mfs_drv_data; #endif @@ -746,7 +753,7 @@ v LOAD_TOKEN(mfs_VersionToken); #endif -/* #define MFS_DEBUG true */ /* temporary */ +// #define MFS_DEBUG true #if defined(MFS_DEBUG) # define DBG( proto ) printf proto # define DBG_BUF(func, bufName, buf, bufSz) mfs_dbg_buf_print(func, bufName, buf, bufSz) @@ -851,15 +858,20 @@ static void mfs_ensure_term_spec(MfsErlDrvData* dataP, int size) "\n term_spec_size: %d\n", dataP->term_spec_index, dataP->term_spec_size) ); - dataP->term_spec_size = (dataP->term_spec_size * 2) + size; + dataP->term_spec_size = TERM_SPEC_SIZE_NEXT(dataP->term_spec_size, size); DBG( ("mfs_ensure_term_spec -> " - "term_spec is at 0x%X, new term_spec_size is %d\n", - (unsigned int) dataP->term_spec, dataP->term_spec_size) ); + "term_spec is at 0x%X, new term_spec_size is %d (%lu)\n", + (unsigned int) dataP->term_spec, + dataP->term_spec_size, + dataP->term_spec_size * sizeof(ErlDrvTermData)) ); tmp = REALLOC(dataP->term_spec, dataP->term_spec_size * sizeof(ErlDrvTermData)); + DBG( ("mfs_ensure_term_spec -> " + "realloc result: 0x%X\n", (unsigned int) tmp) ); + if (tmp == NULL) { /* * Ouch, we did'nt get any new memory. @@ -951,6 +963,9 @@ static void mfs_octet_load_token(ErlDrvTermData TokenTag, int is_empty) ASSIGN_TERM_SPEC(dataP, ERL_DRV_TUPLE); ASSIGN_TERM_SPEC(dataP, 3); + + DBG( ("mfs_octet_load_token -> done\n") ); + } #if defined(MEGACO_REENTRANT_FLEX_SCANNER) @@ -1735,7 +1750,7 @@ static int mfs_control(ErlDrvData handle, dataP->text_buf = tmp; dataP->text_ptr = tmp; - dataP->term_spec_size = 1000 + buf_len; /* OTP-4237 */ + dataP->term_spec_size = TERM_SPEC_SIZE_INITIAL(buf_len); DBG( ("mfs_control -> allocate term-spec buffer: " "\n term_spec_size: %d\n", dataP->term_spec_size) ); -- cgit v1.2.3 From e20a7db2bba04777a54c8d92f873d8322455bb25 Mon Sep 17 00:00:00 2001 From: Micael Karlberg Date: Tue, 26 Mar 2013 16:39:16 +0100 Subject: Ensure of incorrect number of terms when scanning property groups At the end of the mfs_load_property_groups function, the final property group list and property groups list is "terminated". A call to mfs_ensure_term_spec with (incorrect) size 4 was made prior to this to ensure enough data was available. The correct size was 6! --- lib/megaco/src/flex/megaco_flex_scanner_drv.flex.src | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'lib/megaco/src/flex') diff --git a/lib/megaco/src/flex/megaco_flex_scanner_drv.flex.src b/lib/megaco/src/flex/megaco_flex_scanner_drv.flex.src index a8ff86e528..efe817b92d 100644 --- a/lib/megaco/src/flex/megaco_flex_scanner_drv.flex.src +++ b/lib/megaco/src/flex/megaco_flex_scanner_drv.flex.src @@ -103,10 +103,12 @@ typedef struct { /* IBL = In Buffer Length - the raw (un-decoded) message buffer length */ #define TERM_SPEC_SIZE_INITIAL(IBL) (1024 + 2*(IBL)) +// #define TERM_SPEC_SIZE_INITIAL(IBL) (1000 + (IBL)) /* CTSS = Current term spec size - the current term spec length */ /* S = Size - how many positions we need */ #define TERM_SPEC_SIZE_NEXT(CTSS,S) ((CTSS) + 1024 + (S)) +// #define TERM_SPEC_SIZE_NEXT(CTSS,S) (2*(CTSS) + (S)) #if !defined(MEGACO_REENTRANT_FLEX_SCANNER) static MfsErlDrvData mfs_drv_data; @@ -1265,7 +1267,7 @@ static void mfs_load_property_groups(MfsErlDrvData* dataP) } // if ((yytext[i] != SP)... } // while ... - mfs_ensure_term_spec(dataP, 4); // 2 + 2 just in case + mfs_ensure_term_spec(dataP, 6); // 3 + 3 just in case /* Make sure we actually have some groups */ -- cgit v1.2.3 From 6de586ffb9bbc60b15e64a0b9696140093b925f1 Mon Sep 17 00:00:00 2001 From: Micael Karlberg Date: Wed, 3 Apr 2013 11:14:57 +0200 Subject: Removed comments --- lib/megaco/src/flex/megaco_flex_scanner_drv.flex.src | 2 -- 1 file changed, 2 deletions(-) (limited to 'lib/megaco/src/flex') diff --git a/lib/megaco/src/flex/megaco_flex_scanner_drv.flex.src b/lib/megaco/src/flex/megaco_flex_scanner_drv.flex.src index efe817b92d..3520c34d50 100644 --- a/lib/megaco/src/flex/megaco_flex_scanner_drv.flex.src +++ b/lib/megaco/src/flex/megaco_flex_scanner_drv.flex.src @@ -103,12 +103,10 @@ typedef struct { /* IBL = In Buffer Length - the raw (un-decoded) message buffer length */ #define TERM_SPEC_SIZE_INITIAL(IBL) (1024 + 2*(IBL)) -// #define TERM_SPEC_SIZE_INITIAL(IBL) (1000 + (IBL)) /* CTSS = Current term spec size - the current term spec length */ /* S = Size - how many positions we need */ #define TERM_SPEC_SIZE_NEXT(CTSS,S) ((CTSS) + 1024 + (S)) -// #define TERM_SPEC_SIZE_NEXT(CTSS,S) (2*(CTSS) + (S)) #if !defined(MEGACO_REENTRANT_FLEX_SCANNER) static MfsErlDrvData mfs_drv_data; -- cgit v1.2.3 From bb7ba9f1e70a49310efc872f528d91d2a5f4f661 Mon Sep 17 00:00:00 2001 From: Micael Karlberg Date: Wed, 10 Apr 2013 10:39:40 +0200 Subject: Assign correct version and updated release notes accordingly. Also added (and cleaned up) appup. --- lib/megaco/src/flex/megaco_flex_scanner_handler.erl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lib/megaco/src/flex') diff --git a/lib/megaco/src/flex/megaco_flex_scanner_handler.erl b/lib/megaco/src/flex/megaco_flex_scanner_handler.erl index 420202134e..28333ab1d0 100644 --- a/lib/megaco/src/flex/megaco_flex_scanner_handler.erl +++ b/lib/megaco/src/flex/megaco_flex_scanner_handler.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2001-2010. All Rights Reserved. +%% Copyright Ericsson AB 2001-2013. 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 @@ -181,11 +181,11 @@ terminate(_Reason, _S) -> %% Returns: {ok, NewState} %%---------------------------------------------------------------------- -code_change({down, _Vsn}, #state{conf = Conf} = State, downgrade_to_pre_3_13_1) -> +code_change({down, _Vsn}, #state{conf = Conf} = State, downgrade_to_pre_3_14_3) -> NewPorts = bump_flex_scanner(Conf), {ok, State#state{conf = {flex, NewPorts}}}; -code_change(_Vsn, #state{conf = Conf} = State, upgrade_from_pre_3_13_1) -> +code_change(_Vsn, #state{conf = Conf} = State, upgrade_from_pre_3_14_2) -> NewPorts = bump_flex_scanner(Conf), {ok, State#state{conf = {flex, NewPorts}}}; -- cgit v1.2.3 From 1dcfcb31c8d5f0f23e0b836ea0aa85277c71ee17 Mon Sep 17 00:00:00 2001 From: Micael Karlberg Date: Wed, 17 Apr 2013 14:37:10 +0200 Subject: [megaco] Fix merge --- lib/megaco/src/flex/megaco_flex_scanner_drv.flex.src | 6 ------ 1 file changed, 6 deletions(-) (limited to 'lib/megaco/src/flex') diff --git a/lib/megaco/src/flex/megaco_flex_scanner_drv.flex.src b/lib/megaco/src/flex/megaco_flex_scanner_drv.flex.src index e143450ea9..24a0366f58 100644 --- a/lib/megaco/src/flex/megaco_flex_scanner_drv.flex.src +++ b/lib/megaco/src/flex/megaco_flex_scanner_drv.flex.src @@ -1,14 +1,8 @@ /* * %CopyrightBegin% -<<<<<<< HEAD - * - * Copyright Ericsson AB 2001-2011. All Rights Reserved. - * -======= * * Copyright Ericsson AB 2001-2013. All Rights Reserved. * ->>>>>>> bmk/megaco/flex_buffer_overrun_while_scanning_prop_parms/OTP-10998/r14 * 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 * compliance with the License. You should have received a copy of the -- cgit v1.2.3 From 46d8a5961ba734fa4d5d198c481d34aad65c35e5 Mon Sep 17 00:00:00 2001 From: Micael Karlberg Date: Thu, 18 Apr 2013 11:53:47 +0200 Subject: [megaco] Used wrong downgrade tag for (flex) handler --- lib/megaco/src/flex/megaco_flex_scanner_handler.erl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/megaco/src/flex') diff --git a/lib/megaco/src/flex/megaco_flex_scanner_handler.erl b/lib/megaco/src/flex/megaco_flex_scanner_handler.erl index 28333ab1d0..b4c0eeb3d4 100644 --- a/lib/megaco/src/flex/megaco_flex_scanner_handler.erl +++ b/lib/megaco/src/flex/megaco_flex_scanner_handler.erl @@ -181,7 +181,7 @@ terminate(_Reason, _S) -> %% Returns: {ok, NewState} %%---------------------------------------------------------------------- -code_change({down, _Vsn}, #state{conf = Conf} = State, downgrade_to_pre_3_14_3) -> +code_change({down, _Vsn}, #state{conf = Conf} = State, downgrade_to_pre_3_14_2) -> NewPorts = bump_flex_scanner(Conf), {ok, State#state{conf = {flex, NewPorts}}}; -- cgit v1.2.3