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
2a9e2a3c
Commit
2a9e2a3c
authored
Aug 02, 2019
by
Raphael Riebl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
INTEGER: use uintmax_t and intmax_t for UPER decoding and encoding
parent
d13b162a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
17 deletions
+17
-17
skeletons/INTEGER.c
skeletons/INTEGER.c
+17
-17
No files found.
skeletons/INTEGER.c
View file @
2a9e2a3c
...
@@ -636,11 +636,11 @@ INTEGER_decode_uper(const asn_codec_ctx_t *opt_codec_ctx,
...
@@ -636,11 +636,11 @@ INTEGER_decode_uper(const asn_codec_ctx_t *opt_codec_ctx,
/* #11.5.6 */
/* #11.5.6 */
ASN_DEBUG
(
"Integer with range %d bits"
,
ct
->
range_bits
);
ASN_DEBUG
(
"Integer with range %d bits"
,
ct
->
range_bits
);
if
(
ct
->
range_bits
>=
0
)
{
if
(
ct
->
range_bits
>=
0
)
{
if
((
size_t
)
ct
->
range_bits
>
8
*
sizeof
(
u
nsigned
long
))
if
((
size_t
)
ct
->
range_bits
>
8
*
sizeof
(
u
intmax_t
))
ASN__DECODE_FAILED
;
ASN__DECODE_FAILED
;
if
(
specs
&&
specs
->
field_unsigned
)
{
if
(
specs
&&
specs
->
field_unsigned
)
{
u
nsigned
long
uvalue
=
0
;
u
intmax_t
uvalue
=
0
;
if
(
uper_get_constrained_whole_number
(
pd
,
if
(
uper_get_constrained_whole_number
(
pd
,
&
uvalue
,
ct
->
range_bits
))
&
uvalue
,
ct
->
range_bits
))
ASN__DECODE_STARVED
;
ASN__DECODE_STARVED
;
...
@@ -650,8 +650,8 @@ INTEGER_decode_uper(const asn_codec_ctx_t *opt_codec_ctx,
...
@@ -650,8 +650,8 @@ INTEGER_decode_uper(const asn_codec_ctx_t *opt_codec_ctx,
if
(
asn_ulong2INTEGER
(
st
,
uvalue
))
if
(
asn_ulong2INTEGER
(
st
,
uvalue
))
ASN__DECODE_FAILED
;
ASN__DECODE_FAILED
;
}
else
{
}
else
{
u
nsigned
long
uvalue
=
0
;
u
intmax_t
uvalue
=
0
;
long
svalue
;
intmax_t
svalue
;
if
(
uper_get_constrained_whole_number
(
pd
,
if
(
uper_get_constrained_whole_number
(
pd
,
&
uvalue
,
ct
->
range_bits
))
&
uvalue
,
ct
->
range_bits
))
ASN__DECODE_STARVED
;
ASN__DECODE_STARVED
;
...
@@ -659,7 +659,7 @@ INTEGER_decode_uper(const asn_codec_ctx_t *opt_codec_ctx,
...
@@ -659,7 +659,7 @@ INTEGER_decode_uper(const asn_codec_ctx_t *opt_codec_ctx,
uvalue
,
ct
->
lower_bound
);
uvalue
,
ct
->
lower_bound
);
if
(
per_imax_range_unrebase
(
uvalue
,
ct
->
lower_bound
,
if
(
per_imax_range_unrebase
(
uvalue
,
ct
->
lower_bound
,
ct
->
upper_bound
,
&
svalue
)
ct
->
upper_bound
,
&
svalue
)
||
asn_
long
2INTEGER
(
st
,
svalue
))
{
||
asn_
imax
2INTEGER
(
st
,
svalue
))
{
ASN__DECODE_FAILED
;
ASN__DECODE_FAILED
;
}
}
}
}
...
@@ -715,7 +715,7 @@ INTEGER_encode_uper(const asn_TYPE_descriptor_t *td,
...
@@ -715,7 +715,7 @@ INTEGER_encode_uper(const asn_TYPE_descriptor_t *td,
const
uint8_t
*
buf
;
const
uint8_t
*
buf
;
const
uint8_t
*
end
;
const
uint8_t
*
end
;
const
asn_per_constraint_t
*
ct
;
const
asn_per_constraint_t
*
ct
;
long
value
=
0
;
intmax_t
value
=
0
;
if
(
!
st
||
st
->
size
==
0
)
ASN__ENCODE_FAILED
;
if
(
!
st
||
st
->
size
==
0
)
ASN__ENCODE_FAILED
;
...
@@ -727,16 +727,16 @@ INTEGER_encode_uper(const asn_TYPE_descriptor_t *td,
...
@@ -727,16 +727,16 @@ INTEGER_encode_uper(const asn_TYPE_descriptor_t *td,
if
(
ct
)
{
if
(
ct
)
{
int
inext
=
0
;
int
inext
=
0
;
if
(
specs
&&
specs
->
field_unsigned
)
{
if
(
specs
&&
specs
->
field_unsigned
)
{
u
nsigned
long
uval
;
u
intmax_t
uval
;
if
(
asn_INTEGER2u
long
(
st
,
&
uval
))
if
(
asn_INTEGER2u
max
(
st
,
&
uval
))
ASN__ENCODE_FAILED
;
ASN__ENCODE_FAILED
;
/* Check proper range */
/* Check proper range */
if
(
ct
->
flags
&
APC_SEMI_CONSTRAINED
)
{
if
(
ct
->
flags
&
APC_SEMI_CONSTRAINED
)
{
if
(
uval
<
(
u
nsigned
long
)
ct
->
lower_bound
)
if
(
uval
<
(
u
intmax_t
)
ct
->
lower_bound
)
inext
=
1
;
inext
=
1
;
}
else
if
(
ct
->
range_bits
>=
0
)
{
}
else
if
(
ct
->
range_bits
>=
0
)
{
if
(
uval
<
(
u
nsigned
long
)
ct
->
lower_bound
if
(
uval
<
(
u
intmax_t
)
ct
->
lower_bound
||
uval
>
(
u
nsigned
long
)
ct
->
upper_bound
)
||
uval
>
(
u
intmax_t
)
ct
->
upper_bound
)
inext
=
1
;
inext
=
1
;
}
}
ASN_DEBUG
(
"Value %lu (%02x/%"
ASN_PRI_SIZE
") lb %lu ub %lu %s"
,
ASN_DEBUG
(
"Value %lu (%02x/%"
ASN_PRI_SIZE
") lb %lu ub %lu %s"
,
...
@@ -745,7 +745,7 @@ INTEGER_encode_uper(const asn_TYPE_descriptor_t *td,
...
@@ -745,7 +745,7 @@ INTEGER_encode_uper(const asn_TYPE_descriptor_t *td,
inext
?
"ext"
:
"fix"
);
inext
?
"ext"
:
"fix"
);
value
=
uval
;
value
=
uval
;
}
else
{
}
else
{
if
(
asn_INTEGER2
long
(
st
,
&
value
))
if
(
asn_INTEGER2
imax
(
st
,
&
value
))
ASN__ENCODE_FAILED
;
ASN__ENCODE_FAILED
;
/* Check proper range */
/* Check proper range */
if
(
ct
->
flags
&
APC_SEMI_CONSTRAINED
)
{
if
(
ct
->
flags
&
APC_SEMI_CONSTRAINED
)
{
...
@@ -773,20 +773,20 @@ INTEGER_encode_uper(const asn_TYPE_descriptor_t *td,
...
@@ -773,20 +773,20 @@ INTEGER_encode_uper(const asn_TYPE_descriptor_t *td,
/* X.691-11/2008, #13.2.2, test if constrained whole number */
/* X.691-11/2008, #13.2.2, test if constrained whole number */
if
(
ct
&&
ct
->
range_bits
>=
0
)
{
if
(
ct
&&
ct
->
range_bits
>=
0
)
{
unsigned
long
v
;
uintmax_t
v
;
/* #11.5.6 -> #11.3 */
/* #11.5.6 -> #11.3 */
ASN_DEBUG
(
"Encoding integer %ld (%lu) with range %d bits"
,
ASN_DEBUG
(
"Encoding integer %ld (%lu) with range %d bits"
,
value
,
value
-
ct
->
lower_bound
,
ct
->
range_bits
);
value
,
value
-
ct
->
lower_bound
,
ct
->
range_bits
);
if
(
specs
&&
specs
->
field_unsigned
)
{
if
(
specs
&&
specs
->
field_unsigned
)
{
if
(
((
u
nsigned
long
)
ct
->
lower_bound
>
(
unsigned
long
)(
ct
->
upper_bound
)
if
(
((
u
intmax_t
)
ct
->
lower_bound
>
(
uintmax_t
)(
ct
->
upper_bound
)
||
((
u
nsigned
long
)
value
<
(
unsigned
long
)
ct
->
lower_bound
))
||
((
u
intmax_t
)
value
<
(
uintmax_t
)
ct
->
lower_bound
))
||
((
u
nsigned
long
)
value
>
(
unsigned
long
)
ct
->
upper_bound
)
||
((
u
intmax_t
)
value
>
(
uintmax_t
)
ct
->
upper_bound
)
)
{
)
{
ASN_DEBUG
(
"Value %lu to-be-encoded is outside the bounds [%lu, %lu]!"
,
ASN_DEBUG
(
"Value %lu to-be-encoded is outside the bounds [%lu, %lu]!"
,
value
,
ct
->
lower_bound
,
ct
->
upper_bound
);
value
,
ct
->
lower_bound
,
ct
->
upper_bound
);
ASN__ENCODE_FAILED
;
ASN__ENCODE_FAILED
;
}
}
v
=
(
u
nsigned
long
)
value
-
(
unsigned
long
)
ct
->
lower_bound
;
v
=
(
u
intmax_t
)
value
-
(
uintmax_t
)
ct
->
lower_bound
;
}
else
{
}
else
{
if
(
per_imax_range_rebase
(
value
,
ct
->
lower_bound
,
ct
->
upper_bound
,
&
v
))
{
if
(
per_imax_range_rebase
(
value
,
ct
->
lower_bound
,
ct
->
upper_bound
,
&
v
))
{
ASN__ENCODE_FAILED
;
ASN__ENCODE_FAILED
;
...
...
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