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
22cef6cb
Commit
22cef6cb
authored
Oct 16, 2017
by
Lev Walkin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
BMPString and UniversalString fuzz testing
parent
e4a1625a
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
106 additions
and
32 deletions
+106
-32
libasn1compiler/asn1c_C.c
libasn1compiler/asn1c_C.c
+8
-5
skeletons/OCTET_STRING.c
skeletons/OCTET_STRING.c
+33
-23
skeletons/UniversalString.c
skeletons/UniversalString.c
+34
-1
tests/tests-asn1c-compiler/50-constraint-OK.asn1.-Pgen-PER
tests/tests-asn1c-compiler/50-constraint-OK.asn1.-Pgen-PER
+10
-1
tests/tests-randomized/Makefile.am
tests/tests-randomized/Makefile.am
+4
-2
tests/tests-randomized/bundles/10-UTF8String-bundle.txt
tests/tests-randomized/bundles/10-UTF8String-bundle.txt
+3
-0
tests/tests-randomized/bundles/11-BMPString-bundle.txt
tests/tests-randomized/bundles/11-BMPString-bundle.txt
+7
-0
tests/tests-randomized/bundles/12-UniversalString-bundle.txt
tests/tests-randomized/bundles/12-UniversalString-bundle.txt
+7
-0
tests/tests-randomized/bundles/13-UTCTime-bundle.txt
tests/tests-randomized/bundles/13-UTCTime-bundle.txt
+0
-0
tests/tests-randomized/bundles/14-GeneralizedTime-bundle.txt
tests/tests-randomized/bundles/14-GeneralizedTime-bundle.txt
+0
-0
No files found.
libasn1compiler/asn1c_C.c
View file @
22cef6cb
...
...
@@ -2129,7 +2129,9 @@ emit_member_PER_constraints(arg_t *arg, asn1p_expr_t *expr, const char *pfx) {
if
((
arg
->
flags
&
A1C_GEN_PER
)
&&
(
expr
->
combined_constraints
||
etype
==
ASN_BASIC_ENUMERATED
||
etype
==
ASN_CONSTR_CHOICE
)
||
etype
==
ASN_CONSTR_CHOICE
||
(
etype
&
ASN_STRING_KM_MASK
)
)
)
{
/* Fall through */
}
else
{
...
...
@@ -2978,10 +2980,11 @@ emit_type_DEF(arg_t *arg, asn1p_expr_t *expr, enum tvm_compat tv_mode, int tags_
OUT
(
", "
);
if
(
arg
->
flags
&
A1C_GEN_PER
)
{
if
(
expr
->
combined_constraints
||
expr
->
expr_type
==
ASN_BASIC_ENUMERATED
||
expr
->
expr_type
==
ASN_CONSTR_CHOICE
)
{
OUT
(
"&asn_PER_type_%s_constr_%d"
,
if
(
expr
->
combined_constraints
||
expr
->
expr_type
==
ASN_BASIC_ENUMERATED
||
expr
->
expr_type
==
ASN_CONSTR_CHOICE
||
(
expr
->
expr_type
&
ASN_STRING_KM_MASK
))
{
OUT
(
"&asn_PER_type_%s_constr_%d"
,
expr_id
,
expr
->
_type_unique_index
);
}
else
{
OUT
(
"0"
);
...
...
skeletons/OCTET_STRING.c
View file @
22cef6cb
...
...
@@ -1313,28 +1313,32 @@ OCTET_STRING_per_put_characters(asn_per_outp_t *po, const uint8_t *buf,
return
per_put_many_bits
(
po
,
buf
,
unit_bits
*
units
);
}
for
(
ub
-=
lb
;
buf
<
end
;
buf
+=
bpc
)
{
int
ch
;
uint32_t
value
;
switch
(
bpc
)
{
case
1
:
value
=
*
(
const
uint8_t
*
)
buf
;
break
;
case
2
:
value
=
(
buf
[
0
]
<<
8
)
|
buf
[
1
];
break
;
case
4
:
value
=
(
buf
[
0
]
<<
24
)
|
(
buf
[
1
]
<<
16
)
|
(
buf
[
2
]
<<
8
)
|
buf
[
3
];
break
;
default:
return
-
1
;
}
ch
=
value
-
lb
;
if
(
ch
<
0
||
ch
>
ub
)
{
ASN_DEBUG
(
"Character %d (0x%02x)"
" is out of range (%ld..%ld)"
,
*
buf
,
*
buf
,
lb
,
ub
+
lb
);
return
-
1
;
}
if
(
per_put_few_bits
(
po
,
ch
,
unit_bits
))
return
-
1
;
}
for
(
ub
-=
lb
;
buf
<
end
;
buf
+=
bpc
)
{
int
ch
;
uint32_t
value
;
switch
(
bpc
)
{
case
1
:
value
=
*
(
const
uint8_t
*
)
buf
;
break
;
case
2
:
value
=
(
buf
[
0
]
<<
8
)
|
buf
[
1
];
break
;
case
4
:
value
=
(
buf
[
0
]
<<
24
)
|
(
buf
[
1
]
<<
16
)
|
(
buf
[
2
]
<<
8
)
|
buf
[
3
];
break
;
default:
return
-
1
;
}
ch
=
value
-
lb
;
if
(
ch
<
0
||
ch
>
ub
)
{
ASN_DEBUG
(
"Character %d (0x%02x) is out of range (%ld..%ld)"
,
*
buf
,
value
,
lb
,
ub
+
lb
);
return
-
1
;
}
if
(
per_put_few_bits
(
po
,
ch
,
unit_bits
))
return
-
1
;
}
return
0
;
return
0
;
}
static
asn_per_constraints_t
asn_DEF_OCTET_STRING_constraints
=
{
...
...
@@ -1998,13 +2002,19 @@ OCTET_STRING_random_fill(const asn_TYPE_descriptor_t *td, void **sptr,
break
;
case
2
:
for
(
b
=
buf
;
b
<
bend
;
b
+=
unit_bytes
)
{
*
(
uint16_t
*
)
b
=
OCTET_STRING__random_char
(
clb
,
cub
);
uint32_t
code
=
OCTET_STRING__random_char
(
clb
,
cub
);
b
[
0
]
=
code
>>
8
;
b
[
1
]
=
code
;
}
*
(
uint16_t
*
)
b
=
0
;
break
;
case
4
:
for
(
b
=
buf
;
b
<
bend
;
b
+=
unit_bytes
)
{
*
(
uint32_t
*
)
b
=
OCTET_STRING__random_char
(
clb
,
cub
);
uint32_t
code
=
OCTET_STRING__random_char
(
clb
,
cub
);
b
[
0
]
=
code
>>
24
;
b
[
1
]
=
code
>>
16
;
b
[
2
]
=
code
>>
8
;
b
[
3
]
=
code
;
}
*
(
uint32_t
*
)
b
=
0
;
break
;
...
...
skeletons/UniversalString.c
View file @
22cef6cb
/*-
* Copyright (c) 2003
, 2004
Lev Walkin <vlm@lionet.info>. All rights reserved.
* Copyright (c) 2003
-2017
Lev Walkin <vlm@lionet.info>. All rights reserved.
* Redistribution and modifications are permitted subject to BSD license.
*/
#include <asn_internal.h>
...
...
@@ -236,3 +236,36 @@ UniversalString_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
return
0
;
}
/*
* Biased function for randomizing UCS-4 sequences.
*/
static
size_t
UniversalString__random_char
(
uint8_t
*
b
)
{
uint32_t
code
;
switch
(
asn_random_between
(
0
,
4
))
{
case
0
:
code
=
0
;
break
;
case
1
:
code
=
1
;
break
;
case
2
:
code
=
0xd7ff
;
/* End of pre-surrogate block */
break
;
case
3
:
code
=
0xe000
;
/* Beginning of post-surrogate block */
break
;
case
4
:
code
=
0x10ffff
;
break
;
}
b
[
0
]
=
code
>>
24
;
b
[
1
]
=
code
>>
16
;
b
[
2
]
=
code
>>
8
;
b
[
3
]
=
code
;
return
4
;
}
tests/tests-asn1c-compiler/50-constraint-OK.asn1.-Pgen-PER
View file @
22cef6cb
...
...
@@ -472,6 +472,7 @@ typedef IA5String_t Str1_t;
/*** <<< FUNC-DECLS [Str1] >>> ***/
extern asn_per_constraints_t asn_PER_type_Str1_constr_1;
extern asn_TYPE_descriptor_t asn_DEF_Str1;
asn_struct_free_f Str1_free;
asn_struct_print_f Str1_print;
...
...
@@ -490,6 +491,14 @@ per_type_encoder_f Str1_encode_uper;
* so here we adjust the DEF accordingly.
*/
/*** <<< CTDEFS [Str1] >>> ***/
asn_per_constraints_t asn_PER_type_Str1_constr_1 CC_NOTUSED = {
{ APC_CONSTRAINED, 7, 7, 0, 127 } /* (0..127) */,
{ APC_SEMI_CONSTRAINED, -1, -1, 0, 0 } /* (SIZE(0..MAX)) */,
0, 0 /* No PER character map necessary */
};
/*** <<< STAT-DEFS [Str1] >>> ***/
static const ber_tlv_tag_t asn_DEF_Str1_tags_1[] = {
...
...
@@ -505,7 +514,7 @@ asn_TYPE_descriptor_t asn_DEF_Str1 = {
asn_DEF_Str1_tags_1, /* Same as above */
sizeof(asn_DEF_Str1_tags_1)
/sizeof(asn_DEF_Str1_tags_1[0]), /* 1 */
{ 0,
0
, IA5String_constraint },
{ 0,
&asn_PER_type_Str1_constr_1
, IA5String_constraint },
0, 0, /* No members */
0 /* No specifics */
};
...
...
tests/tests-randomized/Makefile.am
View file @
22cef6cb
...
...
@@ -34,8 +34,10 @@ TESTS += bundles/07-VisibleString-bundle.txt
TESTS
+=
bundles/08-OBJECT-IDENTIFIER-bundle.txt
TESTS
+=
bundles/09-RELATIVE-OID-bundle.txt
TESTS
+=
bundles/10-UTF8String-bundle.txt
TESTS
+=
bundles/11-UTCTime-bundle.txt
TESTS
+=
bundles/12-GeneralizedTime-bundle.txt
TESTS
+=
bundles/11-BMPString-bundle.txt
TESTS
+=
bundles/12-UniversalString-bundle.txt
TESTS
+=
bundles/13-UTCTime-bundle.txt
TESTS
+=
bundles/14-GeneralizedTime-bundle.txt
EXTRA_DIST
=
\
random-test-driver.c
\
...
...
tests/tests-randomized/bundles/10-UTF8String-bundle.txt
View file @
22cef6cb
UTF8String
UTF8String (SIZE(0))
UTF8String (SIZE(1))
UTF8String (SIZE(3))
UTF8String (FROM("A".."Z"))
UTF8String (FROM("A".."Z") INTERSECTION SIZE(0))
UTF8String (FROM("A".."Z") INTERSECTION SIZE(3))
tests/tests-randomized/bundles/11-BMPString-bundle.txt
0 → 100644
View file @
22cef6cb
BMPString
BMPString (SIZE(0))
BMPString (SIZE(1))
BMPString (SIZE(3))
BMPString (FROM("A".."Z"))
BMPString (FROM("A".."Z") INTERSECTION SIZE(0))
BMPString (FROM("A".."Z") INTERSECTION SIZE(3))
tests/tests-randomized/bundles/12-UniversalString-bundle.txt
0 → 100644
View file @
22cef6cb
UniversalString
UniversalString (SIZE(0))
UniversalString (SIZE(1))
UniversalString (SIZE(3))
UniversalString (FROM("A".."Z"))
UniversalString (FROM("A".."Z") INTERSECTION SIZE(0))
UniversalString (FROM("A".."Z") INTERSECTION SIZE(3))
tests/tests-randomized/bundles/1
1
-UTCTime-bundle.txt
→
tests/tests-randomized/bundles/1
3
-UTCTime-bundle.txt
View file @
22cef6cb
File moved
tests/tests-randomized/bundles/1
2
-GeneralizedTime-bundle.txt
→
tests/tests-randomized/bundles/1
4
-GeneralizedTime-bundle.txt
View file @
22cef6cb
File moved
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