Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
asn1c
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
asn1c
Commits
42f6c880
Commit
42f6c880
authored
7 years ago
by
Lev Walkin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix OER NULL and SEQUENCE extensions round-trip
parent
a460cbd1
vlm_master
velichkov_s1ap_plus_option_group
No related merge requests found
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
118 additions
and
20 deletions
+118
-20
skeletons/NULL.c
skeletons/NULL.c
+11
-2
skeletons/constr_SEQUENCE.c
skeletons/constr_SEQUENCE.c
+10
-0
skeletons/constr_SEQUENCE_oer.c
skeletons/constr_SEQUENCE_oer.c
+24
-15
skeletons/oer_encoder.c
skeletons/oer_encoder.c
+1
-1
skeletons/oer_encoder.h
skeletons/oer_encoder.h
+2
-2
tests/tests-randomized/Makefile.am
tests/tests-randomized/Makefile.am
+1
-0
tests/tests-randomized/bundles/16-SEQUENCE-bundle.txt
tests/tests-randomized/bundles/16-SEQUENCE-bundle.txt
+69
-0
No files found.
skeletons/NULL.c
View file @
42f6c880
...
...
@@ -135,15 +135,24 @@ NULL_print(const asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
asn_dec_rval_t
NULL_decode_oer
(
const
asn_codec_ctx_t
*
opt_codec_ctx
,
const
asn_TYPE_descriptor_t
*
td
,
const
asn_oer_constraints_t
*
constraints
,
void
**
s
truct_
ptr
,
const
asn_oer_constraints_t
*
constraints
,
void
**
sptr
,
const
void
*
ptr
,
size_t
size
)
{
asn_dec_rval_t
rv
=
{
RC_OK
,
0
};
(
void
)
opt_codec_ctx
;
(
void
)
td
;
(
void
)
constraints
;
(
void
)
struct_ptr
;
(
void
)
ptr
;
(
void
)
size
;
if
(
!*
sptr
)
{
*
sptr
=
MALLOC
(
sizeof
(
NULL_t
));
if
(
*
sptr
)
{
*
(
NULL_t
*
)
*
sptr
=
0
;
}
else
{
ASN__DECODE_FAILED
;
}
}
return
rv
;
}
...
...
This diff is collapsed.
Click to expand it.
skeletons/constr_SEQUENCE.c
View file @
42f6c880
...
...
@@ -1517,8 +1517,18 @@ SEQUENCE_compare(const asn_TYPE_descriptor_t *td, const void *aptr,
*
(
const
void
*
const
*
)((
const
char
*
)
bptr
+
elm
->
memb_offset
);
if
(
!
amemb
)
{
if
(
!
bmemb
)
continue
;
if
(
elm
->
default_value_cmp
&&
elm
->
default_value_cmp
(
bmemb
)
==
0
)
{
/* A is absent, but B is present and equal to DEFAULT */
continue
;
}
return
-
1
;
}
else
if
(
!
bmemb
)
{
if
(
elm
->
default_value_cmp
&&
elm
->
default_value_cmp
(
amemb
)
==
0
)
{
/* B is absent, but A is present and equal to DEFAULT */
continue
;
}
return
1
;
}
}
else
{
...
...
This diff is collapsed.
Click to expand it.
skeletons/constr_SEQUENCE_oer.c
View file @
42f6c880
...
...
@@ -207,9 +207,10 @@ SEQUENCE_decode_oer(const asn_codec_ctx_t *opt_codec_ctx,
memb_ptr2
=
element_ptrptr
(
st
,
elm
,
&
save_memb_ptr
);
rval
=
elm
->
type
->
op
->
oer_decoder
(
opt_codec_ctx
,
elm
->
type
,
elm
->
encoding_constraints
.
oer_constraints
,
memb_ptr2
,
ptr
,
size
);
rval
=
elm
->
type
->
op
->
oer_decoder
(
opt_codec_ctx
,
elm
->
type
,
elm
->
encoding_constraints
.
oer_constraints
,
memb_ptr2
,
ptr
,
size
);
}
switch
(
rval
.
code
)
{
case
RC_OK
:
...
...
@@ -268,7 +269,7 @@ SEQUENCE_decode_oer(const asn_codec_ctx_t *opt_codec_ctx,
len_len
=
oer_fetch_length
(
ptr
,
size
,
&
len
);
if
(
len_len
>
0
)
{
ADVANCE
(
len_len
);
}
if
(
len_len
<
0
)
{
}
else
if
(
len_len
<
0
)
{
RETURN
(
RC_FAIL
);
}
else
{
RETURN
(
RC_WMORE
);
...
...
@@ -314,7 +315,8 @@ SEQUENCE_decode_oer(const asn_codec_ctx_t *opt_codec_ctx,
asn_bit_data_t
*
extadds
=
ctx
->
ptr
;
size_t
edx
=
ctx
->
step
;
asn_TYPE_member_t
*
elm
=
&
td
->
elements
[
edx
];
void
**
memb_ptr2
=
element_ptrptr
(
st
,
elm
,
0
);
void
*
tmp_memb_ptr
;
void
**
memb_ptr2
=
element_ptrptr
(
st
,
elm
,
&
tmp_memb_ptr
);
switch
(
asn_get_few_bits
(
extadds
,
1
))
{
case
-
1
:
...
...
@@ -332,9 +334,11 @@ SEQUENCE_decode_oer(const asn_codec_ctx_t *opt_codec_ctx,
continue
;
case
1
:
{
/* Read OER open type */
ssize_t
ot_size
=
oer_open_type_get
(
opt_codec_ctx
,
elm
->
type
,
ssize_t
ot_size
=
oer_open_type_get
(
opt_codec_ctx
,
elm
->
type
,
elm
->
encoding_constraints
.
oer_constraints
,
memb_ptr2
,
ptr
,
size
);
assert
(
ot_size
<=
(
ssize_t
)
size
);
if
(
ot_size
>
0
)
{
ADVANCE
(
ot_size
);
}
else
if
(
ot_size
<
0
)
{
...
...
@@ -342,8 +346,12 @@ SEQUENCE_decode_oer(const asn_codec_ctx_t *opt_codec_ctx,
}
else
{
/* Roll back open type parsing */
asn_get_undo
(
extadds
,
1
);
if
(
memb_ptr2
==
&
tmp_memb_ptr
)
{
ASN_STRUCT_RESET
(
*
elm
->
type
,
*
memb_ptr2
);
}
else
{
ASN_STRUCT_FREE
(
*
elm
->
type
,
*
memb_ptr2
);
*
memb_ptr2
=
NULL
;
}
RETURN
(
RC_WMORE
);
}
break
;
...
...
@@ -385,7 +393,7 @@ SEQUENCE_decode_oer(const asn_codec_ctx_t *opt_codec_ctx,
}
}
return
rval
;
RETURN
(
RC_OK
)
;
}
/*
...
...
@@ -552,13 +560,14 @@ SEQUENCE_encode_oer(const asn_TYPE_descriptor_t *td,
&&
elm
->
default_value_cmp
(
memb_ptr
)
==
0
)
{
/* Do not encode default value. */
}
else
{
asn_enc_rval_t
er
=
elm
->
type
->
op
->
oer_encoder
(
ssize_t
wrote
=
oer_open_type_put
(
elm
->
type
,
elm
->
encoding_constraints
.
oer_constraints
,
memb_ptr
,
cb
,
app_key
);
if
(
er
.
encoded
==
-
1
)
{
return
er
;
ASN_DEBUG
(
"Open type %s encoded in %zd, +computed=%zu"
,
elm
->
type
->
name
,
wrote
,
computed_size
);
if
(
wrote
==
-
1
)
{
ASN__ENCODE_FAILED
;
}
computed_size
+=
er
.
encoded
;
computed_size
+=
wrote
;
}
}
else
if
(
!
elm
->
optional
)
{
ASN__ENCODE_FAILED
;
...
...
This diff is collapsed.
Click to expand it.
skeletons/oer_encoder.c
View file @
42f6c880
...
...
@@ -136,6 +136,6 @@ oer_open_type_put(const asn_TYPE_descriptor_t *td,
if
(
er
.
encoded
<
0
)
return
-
1
;
assert
(
serialized_byte_count
==
(
size_t
)
er
.
encoded
);
return
er
.
encoded
+
len_len
;
return
len_len
+
er
.
encoded
;
}
This diff is collapsed.
Click to expand it.
skeletons/oer_encoder.h
View file @
42f6c880
...
...
@@ -49,7 +49,7 @@ typedef asn_enc_rval_t(oer_type_encoder_f)(
* Write out the Open Type (X.696 (08/2015), #30).
* RETURN VALUES:
* -1: Fatal error encoding the type.
*
>=0:
Number of bytes serialized.
*
>0:
Number of bytes serialized.
*/
ssize_t
oer_open_type_put
(
const
struct
asn_TYPE_descriptor_s
*
td
,
const
asn_oer_constraints_t
*
constraints
,
...
...
This diff is collapsed.
Click to expand it.
tests/tests-randomized/Makefile.am
View file @
42f6c880
...
...
@@ -40,6 +40,7 @@ TESTS += bundles/12-UniversalString-bundle.txt
TESTS
+=
bundles/13-UTCTime-bundle.txt
TESTS
+=
bundles/14-GeneralizedTime-bundle.txt
TESTS
+=
bundles/15-CHOICE-bundle.txt
TESTS
+=
bundles/16-SEQUENCE-bundle.txt
EXTRA_DIST
=
\
random-test-driver.c
\
...
...
This diff is collapsed.
Click to expand it.
tests/tests-randomized/bundles/16-SEQUENCE-bundle.txt
0 → 100644
View file @
42f6c880
SEQUENCE { }
SEQUENCE { ... }
SEQUENCE { null NULL }
SEQUENCE { null NULL OPTIONAL }
SEQUENCE { ..., null NULL }
SEQUENCE { ..., null NULL OPTIONAL }
SEQUENCE { ..., null BOOLEAN }
SEQUENCE { ..., null BOOLEAN DEFAULT FALSE }
SEQUENCE { ..., null BOOLEAN DEFAULT TRUE }
SEQUENCE { null NULL }
SEQUENCE { null NULL, ... }
SEQUENCE { one NULL, two [2] NULL }
SEQUENCE { one [1] NULL, two [2] NULL }
SEQUENCE { one [2] NULL, two [1] NULL }
SEQUENCE { one [1] NULL, two [3] NULL }
SEQUENCE { one [3] NULL, two [1] NULL }
SEQUENCE { one [3] NULL, two [1] NULL, three [2] NULL }
SEQUENCE { one [4] NULL, two [3] NULL, three [1] NULL, four [2] NULL }
SEQUENCE { one [5] NULL, two [4] NULL, ..., three [3] NULL, four [2] NULL }
SEQUENCE { null NULL, ..., one [5] NULL, two [4] NULL, three [3] NULL, four [2] NULL }
SEQUENCE { one NULL, two [2] NULL, ... }
SEQUENCE { one NULL, ..., two [2] NULL }
SEQUENCE { one NULL, two [2] NULL, ..., three [3] NULL }
SEQUENCE { one NULL, ..., two [2] NULL, three [3] NULL }
SEQUENCE { one BOOLEAN, ..., two [2] BOOLEAN, three [3] BOOLEAN }
SEQUENCE { one BOOLEAN, two BIT STRING (SIZE(1..3)) }
SEQUENCE { null NULL, ..., one BOOLEAN, two BIT STRING (SIZE(1..3)) }
SEQUENCE { one NULL, two BOOLEAN, three BIT STRING (SIZE(1..3)) }
SEQUENCE { null NULL, ..., one [1] NULL, two BOOLEAN, three BIT STRING (SIZE(1..3)) }
SEQUENCE { one NULL, ..., two [2] NULL }
SEQUENCE { one [1] NULL, ..., two [2] NULL }
SEQUENCE { one [2] NULL, ..., two [1] NULL }
SEQUENCE { one [1] NULL, ..., two [3] NULL }
SEQUENCE { one [3] NULL, ..., two [1] NULL }
SEQUENCE { one [3] NULL, ..., two [1] NULL, three [2] NULL }
SEQUENCE { one [4] NULL, ..., two [3] NULL, three [1] NULL, four [2] NULL }
SEQUENCE { one [5] NULL, ..., two [4] NULL, ..., three [3] NULL, four [2] NULL }
SEQUENCE { one NULL, ..., two [2] NULL, ... }
SEQUENCE { one NULL, ..., two [2] NULL, ..., three [3] NULL }
SEQUENCE { one NULL, ..., two [2] NULL, three [3] NULL }
SEQUENCE { one BOOLEAN, ..., two [2] BOOLEAN, three [3] BOOLEAN, ... }
SEQUENCE { one BOOLEAN, ..., two BIT STRING (SIZE(1..3)) }
SEQUENCE { null NULL, ..., one BOOLEAN, two BIT STRING (SIZE(1..3)), ... }
SEQUENCE { one NULL, ..., two BOOLEAN, three BIT STRING (SIZE(1..3)) }
SEQUENCE { null NULL, ..., one [1] NULL, two BOOLEAN, three BIT STRING (SIZE(1..3)), ... }
SEQUENCE { null NULL, ..., one [1] NULL, two BOOLEAN, three BIT STRING (SIZE(1..3)), ..., four IA5String (SIZE(0)) }
SEQUENCE { ..., null NULL }
SEQUENCE { ..., null NULL, ... }
SEQUENCE { ..., one NULL, two [2] NULL }
SEQUENCE { ..., one [1] NULL, two [2] NULL }
SEQUENCE { ..., one [2] NULL, two [1] NULL }
SEQUENCE { ..., one [1] NULL, two [3] NULL }
SEQUENCE { ..., one [3] NULL, two [1] NULL }
SEQUENCE { ..., one [3] NULL, two [1] NULL, three [2] NULL }
SEQUENCE { ..., one [4] NULL, two [3] NULL, three [1] NULL, four [2] NULL }
SEQUENCE { ..., one [5] NULL, two [4] NULL, ..., three [3] NULL, four [2] NULL }
SEQUENCE { ..., null NULL, ..., one [5] NULL, two [4] NULL, three [3] NULL, four [2] NULL }
SEQUENCE { ..., one NULL, two [2] NULL, ... }
SEQUENCE { ..., one NULL, ..., two [2] NULL }
SEQUENCE { ..., one NULL, two [2] NULL, ..., three [3] NULL }
SEQUENCE { ..., one NULL, ..., two [2] NULL, three [3] NULL }
SEQUENCE { ..., one BOOLEAN, ..., two [2] BOOLEAN, three [3] BOOLEAN }
SEQUENCE { ..., one BOOLEAN, two BIT STRING (SIZE(1..3)) }
SEQUENCE { ..., null NULL, ..., one BOOLEAN, two BIT STRING (SIZE(1..3)) }
SEQUENCE { ..., one NULL, two BOOLEAN, three BIT STRING (SIZE(1..3)) }
SEQUENCE { ..., null NULL, ..., one [1] NULL, two BOOLEAN, three BIT STRING (SIZE(1..3)) }
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment