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
53e5ae65
Commit
53e5ae65
authored
7 years ago
by
Lev Walkin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
honor contract wrt zero-termination
parent
8c060139
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
4 deletions
+7
-4
skeletons/REAL.c
skeletons/REAL.c
+2
-2
skeletons/tests/check-REAL.c
skeletons/tests/check-REAL.c
+5
-2
No files found.
skeletons/REAL.c
View file @
53e5ae65
...
...
@@ -512,13 +512,13 @@ asn_REAL2double(const REAL_t *st, double *dbl_value) {
}
/* 1. By contract, an input buffer should be
null
-terminated.
/* 1. By contract, an input buffer should be
'\0'
-terminated.
* OCTET STRING decoder ensures that, as is asn_double2REAL().
* 2. ISO 6093 specifies COMMA as a possible decimal separator.
* However, strtod() can't always deal with COMMA.
* So her we fix both by reallocating, copying and fixing.
*/
if
(
st
->
buf
[
st
->
size
]
||
memchr
(
st
->
buf
,
','
,
st
->
size
))
{
if
(
st
->
buf
[
st
->
size
]
!=
'\0'
||
memchr
(
st
->
buf
,
','
,
st
->
size
))
{
uint8_t
*
p
,
*
end
;
char
*
b
;
if
(
st
->
size
>
100
)
{
...
...
This diff is collapsed.
Click to expand it.
skeletons/tests/check-REAL.c
View file @
53e5ae65
...
...
@@ -167,7 +167,7 @@ check_xer(int fuzzy, double orig_value) {
}
static
void
check_ber_buffer_twoway
(
double
d
,
const
char
*
sample
,
const
char
*
canonical_sample
,
uint8_t
*
inbuf
,
size_t
insize
,
uint8_t
*
outbuf
,
size_t
outsize
,
int
lineno
)
{
check_ber_buffer_twoway
(
double
d
,
const
char
*
sample
,
const
char
*
canonical_sample
,
const
uint8_t
*
inbuf
,
size_t
insize
,
uint8_t
*
outbuf
,
size_t
outsize
,
int
lineno
)
{
REAL_t
rn
;
double
val
;
int
ret
;
...
...
@@ -175,7 +175,9 @@ check_ber_buffer_twoway(double d, const char *sample, const char *canonical_samp
/*
* Decode our expected buffer and check that it matches the given (d).
*/
rn
.
buf
=
inbuf
;
rn
.
buf
=
calloc
(
1
,
insize
+
1
);
/* By convention, buffers have extra \0 */
assert
(
rn
.
buf
);
memcpy
(
rn
.
buf
,
inbuf
,
insize
);
rn
.
size
=
insize
;
asn_REAL2double
(
&
rn
,
&
val
);
if
(
isnan
(
val
))
assert
(
isnan
(
d
));
...
...
@@ -188,6 +190,7 @@ check_ber_buffer_twoway(double d, const char *sample, const char *canonical_samp
/*
* Encode value and check that it matches our expected buffer.
*/
free
(
rn
.
buf
);
memset
(
&
rn
,
0
,
sizeof
(
rn
));
ret
=
asn_double2REAL
(
&
rn
,
d
);
assert
(
ret
==
0
);
...
...
This diff is collapsed.
Click to expand it.
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