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
4ef01a24
Commit
4ef01a24
authored
Sep 06, 2017
by
Lev Walkin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
prohibit encoding universalstring of non-modulo-multiplier size
parent
d523ea45
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
81 additions
and
3 deletions
+81
-3
skeletons/OCTET_STRING.c
skeletons/OCTET_STRING.c
+12
-3
tests/tests-skeletons/Makefile.am
tests/tests-skeletons/Makefile.am
+1
-0
tests/tests-skeletons/check-PER-UniversalString.c
tests/tests-skeletons/check-PER-UniversalString.c
+68
-0
No files found.
skeletons/OCTET_STRING.c
View file @
4ef01a24
...
...
@@ -1572,14 +1572,22 @@ OCTET_STRING_encode_uper(asn_TYPE_descriptor_t *td,
if
(
cval
->
flags
&
APC_CONSTRAINED
)
unit_bits
=
cval
->
range_bits
;
bpc
=
OS__BPC_U16
;
sizeinunits
=
st
->
size
/
2
;
sizeinunits
=
st
->
size
>>
1
;
if
(
st
->
size
&
1
)
{
ASN_DEBUG
(
"%s string size is not modulo 2"
,
td
->
name
);
ASN__ENCODE_FAILED
;
}
break
;
case
ASN_OSUBV_U32
:
canonical_unit_bits
=
unit_bits
=
32
;
if
(
cval
->
flags
&
APC_CONSTRAINED
)
unit_bits
=
cval
->
range_bits
;
bpc
=
OS__BPC_U32
;
sizeinunits
=
st
->
size
/
4
;
sizeinunits
=
st
->
size
>>
2
;
if
(
st
->
size
&
3
)
{
ASN_DEBUG
(
"%s string size is not modulo 4"
,
td
->
name
);
ASN__ENCODE_FAILED
;
}
break
;
}
...
...
@@ -1599,8 +1607,9 @@ OCTET_STRING_encode_uper(asn_TYPE_descriptor_t *td,
csiz
=
&
asn_DEF_OCTET_STRING_constraints
.
size
;
unit_bits
=
canonical_unit_bits
;
inext
=
1
;
}
else
}
else
{
ASN__ENCODE_FAILED
;
}
}
}
else
{
inext
=
0
;
...
...
tests/tests-skeletons/Makefile.am
View file @
4ef01a24
...
...
@@ -13,6 +13,7 @@ check_PROGRAMS = \
check-XER
\
check-OER-INTEGER
\
check-OER-NativeEnumerated
\
check-PER-UniversalString
\
check-PER
\
check-PER-INTEGER
...
...
tests/tests-skeletons/check-PER-UniversalString.c
0 → 100644
View file @
4ef01a24
#include <stdio.h>
#include <assert.h>
#include <sys/time.h>
#include <UniversalString.h>
#include <per_support.h>
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
;
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
));
assert
(
enc
.
encoded
==
-
1
);
ASN_STRUCT_FREE
(
*
td
,
st_in
);
}
static
void
check_round_trip_OK
(
asn_TYPE_descriptor_t
*
td
,
const
char
*
buf
,
size_t
buflen
)
{
uint8_t
uper_output_buffer
[
32
];
UniversalString_t
*
st_in
;
UniversalString_t
*
st_out
=
0
;
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
));
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
);
assert
(
dec
.
consumed
==
enc
.
encoded
);
assert
(
st_in
->
size
==
st_out
->
size
);
assert
(
memcmp
(
st_in
->
buf
,
st_out
->
buf
,
st_in
->
size
)
==
0
);
assert
(
st_out
->
size
==
buflen
);
assert
(
memcmp
(
st_out
->
buf
,
buf
,
buflen
)
==
0
);
ASN_STRUCT_FREE
(
*
td
,
st_in
);
ASN_STRUCT_FREE
(
*
td
,
st_out
);
}
int
main
()
{
static
char
UniversalString_data
[]
=
{
0
,
0
,
0
,
65
,
0
,
0
,
0
,
65
};
check_round_trip_OK
(
&
asn_DEF_UniversalString
,
UniversalString_data
,
0
);
check_encode_failed
(
&
asn_DEF_UniversalString
,
UniversalString_data
,
1
);
check_encode_failed
(
&
asn_DEF_UniversalString
,
UniversalString_data
,
2
);
check_encode_failed
(
&
asn_DEF_UniversalString
,
UniversalString_data
,
3
);
check_round_trip_OK
(
&
asn_DEF_UniversalString
,
UniversalString_data
,
4
);
check_encode_failed
(
&
asn_DEF_UniversalString
,
UniversalString_data
,
5
);
check_encode_failed
(
&
asn_DEF_UniversalString
,
UniversalString_data
,
6
);
check_encode_failed
(
&
asn_DEF_UniversalString
,
UniversalString_data
,
7
);
check_round_trip_OK
(
&
asn_DEF_UniversalString
,
UniversalString_data
,
8
);
return
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