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
Aug 23, 2017
by
Lev Walkin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
honor contract wrt zero-termination
parent
8c060139
Changes
2
Show 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) {
...
@@ -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().
* OCTET STRING decoder ensures that, as is asn_double2REAL().
* 2. ISO 6093 specifies COMMA as a possible decimal separator.
* 2. ISO 6093 specifies COMMA as a possible decimal separator.
* However, strtod() can't always deal with COMMA.
* However, strtod() can't always deal with COMMA.
* So her we fix both by reallocating, copying and fixing.
* 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
;
uint8_t
*
p
,
*
end
;
char
*
b
;
char
*
b
;
if
(
st
->
size
>
100
)
{
if
(
st
->
size
>
100
)
{
...
...
skeletons/tests/check-REAL.c
View file @
53e5ae65
...
@@ -167,7 +167,7 @@ check_xer(int fuzzy, double orig_value) {
...
@@ -167,7 +167,7 @@ check_xer(int fuzzy, double orig_value) {
}
}
static
void
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
;
REAL_t
rn
;
double
val
;
double
val
;
int
ret
;
int
ret
;
...
@@ -175,7 +175,9 @@ check_ber_buffer_twoway(double d, const char *sample, const char *canonical_samp
...
@@ -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).
* 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
;
rn
.
size
=
insize
;
asn_REAL2double
(
&
rn
,
&
val
);
asn_REAL2double
(
&
rn
,
&
val
);
if
(
isnan
(
val
))
assert
(
isnan
(
d
));
if
(
isnan
(
val
))
assert
(
isnan
(
d
));
...
@@ -188,6 +190,7 @@ check_ber_buffer_twoway(double d, const char *sample, const char *canonical_samp
...
@@ -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.
* Encode value and check that it matches our expected buffer.
*/
*/
free
(
rn
.
buf
);
memset
(
&
rn
,
0
,
sizeof
(
rn
));
memset
(
&
rn
,
0
,
sizeof
(
rn
));
ret
=
asn_double2REAL
(
&
rn
,
d
);
ret
=
asn_double2REAL
(
&
rn
,
d
);
assert
(
ret
==
0
);
assert
(
ret
==
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