Commit 509718e0 authored by Elemer Lelik's avatar Elemer Lelik
Browse files

Sync with 5.1.0

parent 694344ac
# Configurations for the Free Open Source Software version
LICENSING := no
USAGE_STATS := no
......@@ -151,8 +151,23 @@ static void check_license_signature(license_raw *lptr)
dsa->g = BN_bin2bn(dsa_g, sizeof(dsa_g), NULL);
dsa->pub_key = BN_bin2bn(dsa_pub_key, sizeof(dsa_pub_key), NULL);
// calculate the right len of the signiture
DSA_SIG *temp_sig=DSA_SIG_new();
int siglen = -1;
const unsigned char *data =lptr->dsa_signature;
if (temp_sig == NULL || d2i_DSA_SIG(&temp_sig,&data,sizeof(lptr->dsa_signature)) == NULL){
fprintf(stderr, "License signature verification failed: %s\n",
ERR_error_string(ERR_get_error(), NULL));
exit(EXIT_FAILURE);
}
unsigned char *tmp_buff= NULL;
siglen = i2d_DSA_SIG(temp_sig, &tmp_buff);
OPENSSL_cleanse(tmp_buff, siglen);
OPENSSL_free(tmp_buff);
DSA_SIG_free(temp_sig);
switch(DSA_verify(0, message_digest, sizeof(message_digest),
lptr->dsa_signature, sizeof(lptr->dsa_signature), dsa)) {
lptr->dsa_signature, siglen, dsa)) {
case 0:
fputs("License file is corrupted: invalid DSA signature.\n", stderr);
exit(EXIT_FAILURE);
......
......@@ -2688,6 +2688,9 @@ void Type::generate_json_schema(JSON_Tokenizer& json, bool embedded, bool as_val
// use the JSON string type and add a pattern to only allow bits or hex digits
json.put_next_token(JSON_TOKEN_NAME, "type");
json.put_next_token(JSON_TOKEN_STRING, "\"string\"");
json.put_next_token(JSON_TOKEN_NAME, "subType");
json.put_next_token(JSON_TOKEN_STRING, (last->typetype == T_OSTR) ? "\"octetstring\"" :
((last->typetype == T_HSTR) ? "\"hexstring\"" : "\"bitstring\""));
json.put_next_token(JSON_TOKEN_NAME, "pattern");
json.put_next_token(JSON_TOKEN_STRING,
(last->typetype == T_OSTR) ? "\"^([0-9A-Fa-f][0-9A-Fa-f])*$\"" :
......@@ -2742,6 +2745,15 @@ void Type::generate_json_schema(JSON_Tokenizer& json, bool embedded, bool as_val
Free(enum_str);
}
json.put_next_token(JSON_TOKEN_ARRAY_END);
// list the numeric values for the enumerated items
json.put_next_token(JSON_TOKEN_NAME, "numericValues");
json.put_next_token(JSON_TOKEN_ARRAY_START);
for (size_t i = 0; i < u.enums.eis->get_nof_eis(); ++i) {
char* num_val_str = mprintf("%lli", get_ei_byIndex(i)->get_value()->get_val_Int()->get_val());
json.put_next_token(JSON_TOKEN_NUMBER, num_val_str);
Free(num_val_str);
}
json.put_next_token(JSON_TOKEN_ARRAY_END);
break;
case T_SEQOF:
case T_SETOF:
......
......@@ -3980,8 +3980,7 @@ void defRecordClass1(const struct_def *sdef, output_struct *output)
src = mputprintf(src,
"int %s::TEXT_decode(const TTCN_Typedescriptor_t& p_td,"
" TTCN_Buffer& p_buf, Limit_Token_List& limit, boolean no_err, boolean){\n"
" if (!is_bound()) TTCN_EncDec_ErrorContext::error"
"(TTCN_EncDec::ET_UNBOUND, \"Encoding an unbound value.\");\n"
" bound_flag = TRUE;\n"
" int decoded_length=0;\n"
" int decoded_field_length=0;\n"
"%s"
......@@ -4242,28 +4241,28 @@ void defRecordClass1(const struct_def *sdef, output_struct *output)
src = mputprintf(src,
"int %s::JSON_decode(const TTCN_Typedescriptor_t&, JSON_Tokenizer& p_tok, boolean p_silent)\n"
"{\n"
" json_token_t token = JSON_TOKEN_NONE;\n"
" int dec_len = p_tok.get_next_token(&token, NULL, NULL);\n"
" if (JSON_TOKEN_ERROR == token) {\n"
" json_token_t j_token = JSON_TOKEN_NONE;\n"
" int dec_len = p_tok.get_next_token(&j_token, NULL, NULL);\n"
" if (JSON_TOKEN_ERROR == j_token) {\n"
" JSON_ERROR(TTCN_EncDec::ET_INVAL_MSG, JSON_DEC_BAD_TOKEN_ERROR, \"\");\n"
" return JSON_ERROR_FATAL;\n"
" }\n"
" else if (JSON_TOKEN_OBJECT_START != token) {\n"
" else if (JSON_TOKEN_OBJECT_START != j_token) {\n"
" return JSON_ERROR_INVALID_TOKEN;\n"
" }\n"
" bound_flag = TRUE;\n\n"
// Read name - value token pairs until we reach some other token
" while (true) {\n"
" char* name = 0;\n"
" char* fld_name = 0;\n"
" size_t name_len = 0;\n"
" size_t buf_pos = p_tok.get_buf_pos();\n"
" dec_len += p_tok.get_next_token(&token, &name, &name_len);\n"
" if (JSON_TOKEN_ERROR == token) {\n"
" dec_len += p_tok.get_next_token(&j_token, &fld_name, &name_len);\n"
" if (JSON_TOKEN_ERROR == j_token) {\n"
" JSON_ERROR(TTCN_EncDec::ET_INVAL_MSG, JSON_DEC_NAME_TOKEN_ERROR);\n"
" return JSON_ERROR_FATAL;\n"
" }\n"
// undo the last action on the buffer
" else if (JSON_TOKEN_NAME != token) {\n"
" else if (JSON_TOKEN_NAME != j_token) {\n"
" p_tok.set_buf_pos(buf_pos);\n"
" break;\n"
" }\n"
......@@ -4272,7 +4271,7 @@ void defRecordClass1(const struct_def *sdef, output_struct *output)
for (i = 0; i < sdef->nElements; ++i) {
src = mputprintf(src,
// check field name
"if (%d == name_len && 0 == strncmp(name, \"%s\", name_len)) {\n"
"if (%d == name_len && 0 == strncmp(fld_name, \"%s\", name_len)) {\n"
" int ret_val = field_%s.JSON_decode(%s_descr_, p_tok, p_silent);\n"
" if (0 > ret_val) {\n"
" if (JSON_ERROR_INVALID_TOKEN) {\n"
......@@ -4290,23 +4289,23 @@ void defRecordClass1(const struct_def *sdef, output_struct *output)
src = mputstr(src,
"{\n"
// invalid field name
" char* name2 = mcopystrn(name, name_len);\n"
" JSON_ERROR(TTCN_EncDec::ET_INVAL_MSG, JSON_DEC_INVALID_NAME_ERROR, name2);\n"
" char* fld_name2 = mcopystrn(fld_name, name_len);\n"
" JSON_ERROR(TTCN_EncDec::ET_INVAL_MSG, JSON_DEC_INVALID_NAME_ERROR, fld_name2);\n"
// if this is set to a warning, skip the value of the field
" dec_len += p_tok.get_next_token(&token, NULL, NULL);\n"
" if (JSON_TOKEN_NUMBER != token && JSON_TOKEN_STRING != token &&\n"
" JSON_TOKEN_LITERAL_TRUE != token && JSON_TOKEN_LITERAL_FALSE != token &&\n"
" JSON_TOKEN_LITERAL_NULL != token) {\n"
" JSON_ERROR(TTCN_EncDec::ET_INVAL_MSG, JSON_DEC_FIELD_TOKEN_ERROR, name2);\n"
" Free(name2);\n"
" dec_len += p_tok.get_next_token(&j_token, NULL, NULL);\n"
" if (JSON_TOKEN_NUMBER != j_token && JSON_TOKEN_STRING != j_token &&\n"
" JSON_TOKEN_LITERAL_TRUE != j_token && JSON_TOKEN_LITERAL_FALSE != j_token &&\n"
" JSON_TOKEN_LITERAL_NULL != j_token) {\n"
" JSON_ERROR(TTCN_EncDec::ET_INVAL_MSG, JSON_DEC_FIELD_TOKEN_ERROR, fld_name2);\n"
" Free(fld_name2);\n"
" return JSON_ERROR_FATAL;\n"
" }\n"
" Free(name2);\n"
" Free(fld_name2);\n"
" }\n"
" }\n"
" }\n\n"
" dec_len += p_tok.get_next_token(&token, NULL, NULL);\n"
" if (JSON_TOKEN_OBJECT_END != token) {\n"
" dec_len += p_tok.get_next_token(&j_token, NULL, NULL);\n"
" if (JSON_TOKEN_OBJECT_END != j_token) {\n"
" JSON_ERROR(TTCN_EncDec::ET_INVAL_MSG, JSON_DEC_OBJECT_END_TOKEN_ERROR, \"\");\n"
" return JSON_ERROR_FATAL;\n"
" }\n\n");
......@@ -4334,7 +4333,7 @@ void defRecordClass1(const struct_def *sdef, output_struct *output)
" }\n");
}
src = mputstr(src,
"\n return dec_len;"
"\n return dec_len;\n"
"}\n\n");
}
......@@ -5706,6 +5705,7 @@ static void defEmptyRecordClass(const struct_def *sdef,
src = mputprintf(src,
"int %s::TEXT_decode(const TTCN_Typedescriptor_t& p_td,"
" TTCN_Buffer& p_buf, Limit_Token_List& limit, boolean no_err, boolean){\n"
" bound_flag = TRUE;\n"
" int decoded_length=0;\n"
" if(p_td.text->begin_decode){\n"
" int tl;\n"
......@@ -5733,7 +5733,6 @@ static void defEmptyRecordClass(const struct_def *sdef,
" decoded_length+=tl;\n"
" p_buf.increase_pos(tl);\n"
" }\n"
"bound_flag = TRUE;\n"
" return decoded_length;\n"
"}\n"
,name
......
......@@ -9526,10 +9526,17 @@ namespace Ttcn {
// let the array object know that the index is referenced before
// calling the function, and let it know that it's now longer
// referenced after the function call
expr->preamble = mputprintf(expr->preamble, "%s.add_refd_index(%s);\n",
array_expr.expr, index_expr.expr);
expr->postamble = mputprintf(expr->postamble, "%s.remove_refd_index(%s);\n",
array_expr.expr, index_expr.expr);
string tmp_id = ref->get_my_scope()->get_scope_mod_gen()->get_temporary_id();
expr->preamble = mputprintf(expr->preamble,
"INTEGER %s = %s;\n"
"%s.add_refd_index(%s);\n",
tmp_id.c_str(), index_expr.expr, array_expr.expr, index_expr.expr);
expr->postamble = mputprintf(expr->postamble,
"%s.remove_refd_index(%s);\n"
"if (%s >= %s.size_of()) TTCN_warning(\""
"Warning: possibly incompatible behaviour related to TR HT24380;"
" for details see release notes\");\n",
array_expr.expr, index_expr.expr, tmp_id.c_str(), array_expr.expr);
// insert any postambles the array object or the index might have
if (array_expr.postamble != NULL) {
expr->preamble = mputstr(expr->preamble, array_expr.postamble);
......
......@@ -1790,16 +1790,16 @@ void defUnionClass(struct_def const *sdef, output_struct *output)
// JSON decode
src = mputprintf(src,
"int %s::JSON_decode(const TTCN_Typedescriptor_t& p_td, JSON_Tokenizer& p_tok, boolean p_silent)\n"
"int %s::JSON_decode(const TTCN_Typedescriptor_t&, JSON_Tokenizer& p_tok, boolean p_silent)\n"
"{\n"
" json_token_t token = JSON_TOKEN_NONE;\n"
" json_token_t j_token = JSON_TOKEN_NONE;\n"
, name);
if (sdef->jsonAsValue) {
src = mputstr(src,
" size_t buf_pos = p_tok.get_buf_pos();\n"
" p_tok.get_next_token(&token, NULL, NULL);\n"
" p_tok.get_next_token(&j_token, NULL, NULL);\n"
" int ret_val = 0;\n"
" switch(token) {\n"
" switch(j_token) {\n"
" case JSON_TOKEN_NUMBER: {\n");
for (i = 0; i < sdef->nElements; ++i) {
if (JSON_NUMBER & sdef->elements[i].jsonValueType) {
......@@ -1849,11 +1849,11 @@ void defUnionClass(struct_def const *sdef, output_struct *output)
}
}
src = mputstr(src,
" char* literal = mprintf(\"literal (%s)\",\n"
" (JSON_TOKEN_LITERAL_TRUE == token) ? \"true\" :\n"
" ((JSON_TOKEN_LITERAL_FALSE == token) ? \"false\" : \"null\"));\n"
" JSON_ERROR(TTCN_EncDec::ET_INVAL_MSG, JSON_DEC_AS_VALUE_ERROR, literal);\n"
" Free(literal);\n"
" char* literal_str = mprintf(\"literal (%s)\",\n"
" (JSON_TOKEN_LITERAL_TRUE == j_token) ? \"true\" :\n"
" ((JSON_TOKEN_LITERAL_FALSE == j_token) ? \"false\" : \"null\"));\n"
" JSON_ERROR(TTCN_EncDec::ET_INVAL_MSG, JSON_DEC_AS_VALUE_ERROR, literal_str);\n"
" Free(literal_str);\n"
" clean_up();\n"
" return JSON_ERROR_FATAL;\n"
" }\n"
......@@ -1901,18 +1901,18 @@ void defUnionClass(struct_def const *sdef, output_struct *output)
"}\n\n");
} else { // not "as value"
src = mputprintf(src,
" int dec_len = p_tok.get_next_token(&token, NULL, NULL);\n"
" if (JSON_TOKEN_ERROR == token) {\n"
" int dec_len = p_tok.get_next_token(&j_token, NULL, NULL);\n"
" if (JSON_TOKEN_ERROR == j_token) {\n"
" JSON_ERROR(TTCN_EncDec::ET_INVAL_MSG, JSON_DEC_BAD_TOKEN_ERROR, \"\");\n"
" return JSON_ERROR_FATAL;\n"
" }\n"
" else if (JSON_TOKEN_OBJECT_START != token) {\n"
" else if (JSON_TOKEN_OBJECT_START != j_token) {\n"
" return JSON_ERROR_INVALID_TOKEN;\n"
" }\n\n"
" char* name = 0;\n"
" char* fld_name = 0;\n"
" size_t name_len = 0;"
" dec_len += p_tok.get_next_token(&token, &name, &name_len);\n"
" if (JSON_TOKEN_NAME != token) {\n"
" dec_len += p_tok.get_next_token(&j_token, &fld_name, &name_len);\n"
" if (JSON_TOKEN_NAME != j_token) {\n"
" JSON_ERROR(TTCN_EncDec::ET_INVAL_MSG, JSON_DEC_NAME_TOKEN_ERROR);\n"
" return JSON_ERROR_FATAL;\n"
" } else {\n"
......@@ -1920,7 +1920,7 @@ void defUnionClass(struct_def const *sdef, output_struct *output)
, unbound_value);
for (i = 0; i < sdef->nElements; ++i) {
src = mputprintf(src,
"if (0 == strncmp(name, \"%s\", name_len)) {\n"
"if (0 == strncmp(fld_name, \"%s\", name_len)) {\n"
" int ret_val = %s%s().JSON_decode(%s_descr_, p_tok, p_silent);\n"
" if (0 > ret_val) {\n"
" if (JSON_ERROR_INVALID_TOKEN) {\n"
......@@ -1937,14 +1937,14 @@ void defUnionClass(struct_def const *sdef, output_struct *output)
}
src = mputstr(src,
"{\n"
" char* name2 = mcopystrn(name, name_len);\n"
" JSON_ERROR(TTCN_EncDec::ET_INVAL_MSG, JSON_DEC_INVALID_NAME_ERROR, name2);\n"
" Free(name2);\n"
" char* fld_name2 = mcopystrn(fld_name, name_len);\n"
" JSON_ERROR(TTCN_EncDec::ET_INVAL_MSG, JSON_DEC_INVALID_NAME_ERROR, fld_name2);\n"
" Free(fld_name2);\n"
" return JSON_ERROR_FATAL;\n"
" }\n"
" }\n\n"
" dec_len += p_tok.get_next_token(&token, NULL, NULL);\n"
" if (JSON_TOKEN_OBJECT_END != token) {\n"
" dec_len += p_tok.get_next_token(&j_token, NULL, NULL);\n"
" if (JSON_TOKEN_OBJECT_END != j_token) {\n"
" JSON_ERROR(TTCN_EncDec::ET_INVAL_MSG, JSON_DEC_STATIC_OBJECT_END_TOKEN_ERROR, \"\");\n"
" return JSON_ERROR_FATAL;\n"
" }\n\n"
......
......@@ -284,6 +284,12 @@ public:
* 'inout' or 'out' parameter to a function.
* Redirects the call to the optional value. */
void remove_refd_index(int index);
/** Called before an element of an optional record of/set of is passed as an
* 'inout' or 'out' parameter to a function. Returns the size of the record of/
* set of.
* Redirects the call to the optional value. */
int size_of();
};
#if HAVE_GCC(4,6)
......@@ -676,6 +682,15 @@ void OPTIONAL<T_type>::remove_refd_index(int index)
optional_value->remove_refd_index(index);
}
template<typename T_type>
int OPTIONAL<T_type>::size_of()
{
if (!is_present()) {
return 0;
}
return optional_value->size_of();
}
template<typename T_type>
OPTIONAL<T_type>::operator T_type&()
{
......
......@@ -97,6 +97,7 @@ XML Schema for JunitLogger plugin
<xs:element name="forceXERinASN.1" minOccurs="0" maxOccurs="1" type="xs:boolean" />
<xs:element name="defaultasOmit" minOccurs="0" maxOccurs="1" type="xs:boolean" />
<xs:element name="enumHackProperty" minOccurs="0" maxOccurs="1" type="xs:boolean" />
<xs:element name="forceOldFuncOutParHandling" minOccurs="0" maxOccurs="1" type="xs:boolean" />
<xs:element name="gccMessageFormat" minOccurs="0" maxOccurs="1" type="xs:boolean" />
<xs:element name="lineNumbersOnlyInMessages" minOccurs="0" maxOccurs="1" type="xs:boolean" />
<xs:element name="includeSourceInfo" minOccurs="0" maxOccurs="1" type="xs:boolean" />
......
!Makefile
!*.ttcn
\ No newline at end of file
!Makefile
!*.ttcn
\ No newline at end of file
!Makefile
!*.ttcn
\ No newline at end of file
compiler.exe.stackdump
!Makefile
!*.ttcn
\ No newline at end of file
!Makefile
!*.ttcn
\ No newline at end of file
......@@ -3,3 +3,5 @@
*_OK_union.cc
goodprog
goodprog.exe
!Makefile
!*.ttcn
......@@ -3,3 +3,5 @@
*_OK_union.cc
goodprog
goodprog.exe
!Makefile
!*.ttcn
......@@ -22,3 +22,4 @@ DFE*Test.ttcn
Marx.ttcn
Regressions.ttcn
*.d
!Flatten.cc
\ No newline at end of file
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