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
b7a202e5
Commit
b7a202e5
authored
Sep 06, 2017
by
Lev Walkin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
check length size in default BMPString and UniversalString constraints
parent
86526e3f
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
65 additions
and
8 deletions
+65
-8
skeletons/BMPString.c
skeletons/BMPString.c
+24
-2
skeletons/BMPString.h
skeletons/BMPString.h
+1
-0
skeletons/UniversalString.c
skeletons/UniversalString.c
+23
-2
skeletons/UniversalString.h
skeletons/UniversalString.h
+1
-0
tests/tests-skeletons/check-PER-UniversalString.c
tests/tests-skeletons/check-PER-UniversalString.c
+16
-4
No files found.
skeletons/BMPString.c
View file @
b7a202e5
...
...
@@ -27,7 +27,7 @@ asn_TYPE_operation_t asn_OP_BMPString = {
OCTET_STRING_free
,
/* Implemented in terms of OCTET STRING */
BMPString_print
,
OCTET_STRING_compare
,
asn_generic_no_constraint
,
/* No constraint by default */
BMPString_constraint
,
OCTET_STRING_decode_ber
,
OCTET_STRING_encode_der
,
BMPString_decode_xer
,
/* Convert from UTF-8 */
...
...
@@ -52,7 +52,7 @@ asn_TYPE_descriptor_t asn_DEF_BMPString = {
"BMPString"
,
"BMPString"
,
&
asn_OP_BMPString
,
asn_generic_no_constraint
,
/* No constraint by default */
BMPString_constraint
,
asn_DEF_BMPString_tags
,
sizeof
(
asn_DEF_BMPString_tags
)
/
sizeof
(
asn_DEF_BMPString_tags
[
0
])
-
1
,
...
...
@@ -65,6 +65,28 @@ asn_TYPE_descriptor_t asn_DEF_BMPString = {
&
asn_SPC_BMPString_specs
};
int
BMPString_constraint
(
asn_TYPE_descriptor_t
*
td
,
const
void
*
sptr
,
asn_app_constraint_failed_f
*
ctfailcb
,
void
*
app_key
)
{
const
BMPString_t
*
st
=
(
const
BMPString_t
*
)
sptr
;
if
(
st
&&
st
->
buf
)
{
if
(
st
->
size
&
1
)
{
ASN__CTFAIL
(
app_key
,
td
,
sptr
,
"%s: invalid size %zu not divisible by 2 (%s:%d)"
,
td
->
name
,
st
->
size
,
__FILE__
,
__LINE__
);
return
-
1
;
}
}
else
{
ASN__CTFAIL
(
app_key
,
td
,
sptr
,
"%s: value not given (%s:%d)"
,
td
->
name
,
__FILE__
,
__LINE__
);
return
-
1
;
}
return
0
;
}
/*
* BMPString specific contents printer.
*/
...
...
skeletons/BMPString.h
View file @
b7a202e5
...
...
@@ -18,6 +18,7 @@ extern asn_TYPE_operation_t asn_OP_BMPString;
extern
asn_OCTET_STRING_specifics_t
asn_SPC_BMPString_specs
;
asn_struct_print_f
BMPString_print
;
/* Human-readable output */
asn_constr_check_f
BMPString_constraint
;
xer_type_decoder_f
BMPString_decode_xer
;
xer_type_encoder_f
BMPString_encode_xer
;
...
...
skeletons/UniversalString.c
View file @
b7a202e5
...
...
@@ -27,7 +27,7 @@ asn_TYPE_operation_t asn_OP_UniversalString = {
OCTET_STRING_free
,
UniversalString_print
,
/* Convert into UTF8 and print */
OCTET_STRING_compare
,
asn_generic_no
_constraint
,
UniversalString
_constraint
,
OCTET_STRING_decode_ber
,
OCTET_STRING_encode_der
,
UniversalString_decode_xer
,
/* Convert from UTF-8 */
...
...
@@ -52,7 +52,7 @@ asn_TYPE_descriptor_t asn_DEF_UniversalString = {
"UniversalString"
,
"UniversalString"
,
&
asn_OP_UniversalString
,
asn_generic_no
_constraint
,
UniversalString
_constraint
,
asn_DEF_UniversalString_tags
,
sizeof
(
asn_DEF_UniversalString_tags
)
/
sizeof
(
asn_DEF_UniversalString_tags
[
0
])
-
1
,
...
...
@@ -65,6 +65,27 @@ asn_TYPE_descriptor_t asn_DEF_UniversalString = {
&
asn_SPC_UniversalString_specs
};
int
UniversalString_constraint
(
asn_TYPE_descriptor_t
*
td
,
const
void
*
sptr
,
asn_app_constraint_failed_f
*
ctfailcb
,
void
*
app_key
)
{
const
UniversalString_t
*
st
=
(
const
UniversalString_t
*
)
sptr
;
if
(
st
&&
st
->
buf
)
{
if
(
st
->
size
&
3
)
{
ASN__CTFAIL
(
app_key
,
td
,
sptr
,
"%s: invalid size %zu not divisible by 4 (%s:%d)"
,
td
->
name
,
st
->
size
,
__FILE__
,
__LINE__
);
return
-
1
;
}
}
else
{
ASN__CTFAIL
(
app_key
,
td
,
sptr
,
"%s: value not given (%s:%d)"
,
td
->
name
,
__FILE__
,
__LINE__
);
return
-
1
;
}
return
0
;
}
static
ssize_t
UniversalString__dump
(
const
UniversalString_t
*
st
,
...
...
skeletons/UniversalString.h
View file @
b7a202e5
...
...
@@ -18,6 +18,7 @@ extern asn_TYPE_operation_t asn_OP_UniversalString;
extern
asn_OCTET_STRING_specifics_t
asn_SPC_UniversalString_specs
;
asn_struct_print_f
UniversalString_print
;
/* Human-readable output */
asn_constr_check_f
UniversalString_constraint
;
xer_type_decoder_f
UniversalString_decode_xer
;
xer_type_encoder_f
UniversalString_encode_xer
;
...
...
tests/tests-skeletons/check-PER-UniversalString.c
View file @
b7a202e5
...
...
@@ -9,13 +9,21 @@ static void
check_encode_failed
(
asn_TYPE_descriptor_t
*
td
,
const
char
*
buf
,
size_t
buflen
)
{
uint8_t
uper_output_buffer
[
32
];
UniversalString_t
*
st_in
;
char
error_buf
[
128
];
size_t
error_buf_len
=
sizeof
(
error_buf
);
st_in
=
OCTET_STRING_new_fromBuf
(
td
,
buf
,
buflen
);
assert
(
st_in
);
assert
(
st_in
->
size
==
buflen
);
asn_enc_rval_t
enc
=
uper_encode_to_buffer
(
&
asn_DEF_UniversalString
,
st_in
,
uper_output_buffer
,
sizeof
(
uper_output_buffer
));
/* First signal that something is wrong with the length */
int
st_in_ct
=
asn_check_constraints
(
td
,
st_in
,
error_buf
,
&
error_buf_len
);
assert
(
st_in_ct
!=
0
);
fprintf
(
stderr
,
"%s
\n
"
,
error_buf
);
/* Second signal that something is wrong with the length */
asn_enc_rval_t
enc
=
uper_encode_to_buffer
(
td
,
st_in
,
uper_output_buffer
,
sizeof
(
uper_output_buffer
));
assert
(
enc
.
encoded
==
-
1
);
ASN_STRUCT_FREE
(
*
td
,
st_in
);
...
...
@@ -31,14 +39,18 @@ check_round_trip_OK(asn_TYPE_descriptor_t *td, const char *buf, size_t buflen) {
assert
(
st_in
);
assert
(
st_in
->
size
==
buflen
);
int
st_in_ct
=
asn_check_constraints
(
td
,
st_in
,
NULL
,
NULL
);
assert
(
st_in_ct
==
0
);
asn_enc_rval_t
enc
=
uper_encode_to_buffer
(
&
asn_DEF_UniversalString
,
st_in
,
uper_encode_to_buffer
(
td
,
st_in
,
uper_output_buffer
,
sizeof
(
uper_output_buffer
));
assert
(
enc
.
encoded
>
0
);
asn_dec_rval_t
dec
=
uper_decode
(
0
,
&
asn_DEF_UniversalString
,
(
void
**
)
&
st_out
,
uper_output_buffer
,
(
enc
.
encoded
+
7
)
/
8
,
0
,
0
);
int
st_out_ct
=
asn_check_constraints
(
td
,
st_out
,
NULL
,
NULL
);
assert
(
st_out_ct
==
0
);
assert
(
dec
.
consumed
==
enc
.
encoded
);
assert
(
st_in
->
size
==
st_out
->
size
);
assert
(
memcmp
(
st_in
->
buf
,
st_out
->
buf
,
st_in
->
size
)
==
0
);
...
...
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