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
ccf897b5
Commit
ccf897b5
authored
Jul 07, 2022
by
Pau Espin Pedrol
Committed by
Mouse
Jul 11, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
APER encoding: Fix aper_put_nsnnwn when value > range
parent
60ee1206
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
2 deletions
+16
-2
skeletons/aper_support.c
skeletons/aper_support.c
+4
-0
tests/tests-skeletons/check-APER-support.c
tests/tests-skeletons/check-APER-support.c
+12
-2
No files found.
skeletons/aper_support.c
View file @
ccf897b5
...
...
@@ -232,8 +232,12 @@ aper_put_nsnnwn(asn_per_outp_t *po, int range, int number) {
}
return
per_put_few_bits
(
po
,
number
,
i
);
}
else
if
(
range
==
256
)
{
if
(
number
>=
range
)
return
-
1
;
bytes
=
1
;
}
else
if
(
range
<=
65536
)
{
if
(
number
>=
range
)
return
-
1
;
bytes
=
2
;
}
else
{
/* Ranges > 64K */
int
i
;
...
...
tests/tests-skeletons/check-APER-support.c
View file @
ccf897b5
...
...
@@ -77,6 +77,7 @@ check_round_trips_range65536() {
check_round_trip
(
65536
,
65534
);
check_round_trip
(
65536
,
65535
);
check_round_trip
(
65536
,
65536
);
/* BUG: ^ this should fail but there's another unrelated bug, will be fixed in follow-up commit */
}
/*
...
...
@@ -87,12 +88,21 @@ check_encode_number_greater_than_range() {
asn_per_outp_t
po
;
int
range
=
6500
;
size_t
length
=
6503
;
ssize_t
may_write
;
memset
(
&
po
,
0
,
sizeof
(
po
));
po
.
buffer
=
po
.
tmpspace
;
po
.
nbits
=
8
*
sizeof
(
po
.
tmpspace
);
ssize_t
may_write
=
aper_put_length
(
&
po
,
range
,
length
,
NULL
);
assert
(
may_write
>=
0
);
/* BUG, this should fail! */
may_write
=
aper_put_length
(
&
po
,
range
,
length
,
NULL
);
assert
(
may_write
<
0
);
/* Also check value = range should fail: */
memset
(
&
po
,
0
,
sizeof
(
po
));
po
.
buffer
=
po
.
tmpspace
;
po
.
nbits
=
8
*
sizeof
(
po
.
tmpspace
);
length
=
range
;
may_write
=
aper_put_length
(
&
po
,
range
,
length
,
NULL
);
assert
(
may_write
<
0
);
}
int
main
()
{
...
...
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