Commit 247d8833 authored by BenceJanosSzabo's avatar BenceJanosSzabo
Browse files

Bug 492231 - RAW decoder: dynamic test case error during decoding: Invalid...


Bug 492231 - RAW decoder: dynamic test case error during decoding: Invalid conversion of a large integer value

Change-Id: I5f49e68a7ad160672b34192922c3859d22594ce1
Signed-off-by: default avatarBenceJanosSzabo <bence.janos.szabo@ericsson.com>
parent 7dd6f23d
......@@ -4884,7 +4884,7 @@ static char *genRawDecodeRecordField(char *src, const struct_def *sdef,
);
}
src=mputprintf(src,
" value_of_length_field%d+=(int)field_%s%s.%s%s()*%d;\n"
" value_of_length_field%d+=field_%s%s.%s%s().get_long_long_val()*%d;\n"
,i,sdef->elements[i].name,sdef->elements[i].isOptional?"()":""
,sdef->elements[i].raw.lengthindex->nthfieldname
,sdef->elements[i].raw.lengthindex->fieldtype == OPTIONAL_FIELD?"()":""
......@@ -4902,7 +4902,7 @@ static char *genRawDecodeRecordField(char *src, const struct_def *sdef,
sdef->elements[i].name, sdef->elements[i].isOptional ? "()" : "");
for (m = 1; m < sdef->elements[i].raw.union_member_num + 1; m++) {
src = mputprintf(src, " case %s%s%s:\n"
" value_of_length_field%d += (int)field_%s%s.%s() * %d;\n"
" value_of_length_field%d += field_%s%s.%s().get_long_long_val() * %d;\n"
" break;\n", sdef->elements[i].raw.member_name[0],
"::ALT_",
sdef->elements[i].raw.member_name[m], i, sdef->elements[i].name,
......@@ -4916,7 +4916,7 @@ static char *genRawDecodeRecordField(char *src, const struct_def *sdef,
}
else{
src=mputprintf(src,
" value_of_length_field%d+=(int)field_%s%s*%d;\n"
" value_of_length_field%d+=field_%s%s.get_long_long_val()*%d;\n"
,i,sdef->elements[i].name,sdef->elements[i].isOptional?"()":""
,sdef->elements[i].raw.unit==-1?1:sdef->elements[i].raw.unit
);
......
......@@ -414,15 +414,15 @@ void free_tree_pos(int* ptr){
Free(ptr);
}
int min_of_ints(int num_of_int,...)
int min_of_ints(unsigned int num_of_int,...)
{
va_list pvar;
va_start(pvar,num_of_int);
int min_val = 0;
unsigned int min_val = 0;
if (num_of_int > 0) {
min_val = va_arg(pvar, int);
for (int a = 1; a < num_of_int; a++) {
int b = va_arg(pvar, int);
min_val = va_arg(pvar, unsigned int);
for (unsigned int a = 1; a < num_of_int; a++) {
unsigned int b = va_arg(pvar, unsigned int);
if (b < min_val) min_val = b;
}
}
......
......@@ -201,7 +201,7 @@ RAW_enc_tree** init_nodes_of_enc_tree(int nodes_num);
RAW_enc_tr_pos* init_lengthto_fields_list(int num);
int* init_new_tree_pos(RAW_enc_tr_pos &old_pos,int new_levels, int* new_pos);
void free_tree_pos(int* ptr);
int min_of_ints(int num_of_int, ...);
int min_of_ints(unsigned num_of_int, ...);
extern const TTCN_RAWdescriptor_t INTEGER_raw_;
extern const TTCN_RAWdescriptor_t BOOLEAN_raw_;
......
......@@ -7332,6 +7332,74 @@ control{
Overall verdict: pass
<END_TC>
:exmp.
.*---------------------------------------------------------------------*
:h3. Bug 492231: RAW coder: incorrect (int) conversion in generated code.
.*---------------------------------------------------------------------*
:xmp tab=0.
<TC-Bug 492231: RAW coder: incorrect (int) conversion in generated code.>
<STATIC>
type component Test_CT{};
<TTCN_TC:PURE_EXEC>
external function enc_U(in U pl_pdu) return octetstring
with {
extension "prototype(convert)"
extension "encode(RAW)"
};
external function dec_U(in octetstring pl_octetstring) return U
with {
extension "prototype(convert)"
extension "decode(RAW)"
}
type octetstring OCT2 length(2);
type record R1 {
integer f1,
octetstring f2,
integer f3
} with {
encode "RAW"
variant (f1) "FIELDLENGTH(64)"
variant (f1) "LENGTHTO(f2)"
}
type union U {
R1 u1,
octetstring u2 length(8)
} with {
encode "RAW"
variant ""
}
testcase TC_01() runs on Test_CT{
var U pl_u, pl_u_result;
pl_u.u2 := 'FFFFFFFFFFFFFFFF'O;
var octetstring os := enc_U(pl_u);
pl_u_result := dec_U(os);
if (pl_u != pl_u_result) {
setverdict(fail);
}
setverdict(pass);
}
control{
execute(TC_01());
}
<RESULT>
Overall verdict: pass
<END_TC>
:exmp.
.*---------------------------------------------------------------------*
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment