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
5b63acf7
Commit
5b63acf7
authored
Jan 14, 2014
by
Lev Walkin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove errors with ./configure --enable-Werror
parent
aef10c36
Changes
15
Show whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
151 additions
and
135 deletions
+151
-135
asn1c/tests/check-119.-fwide-types.-gen-PER.c
asn1c/tests/check-119.-fwide-types.-gen-PER.c
+15
-12
asn1c/tests/check-119.-gen-PER.c
asn1c/tests/check-119.-gen-PER.c
+17
-12
asn1c/tests/check-126.-gen-PER.c
asn1c/tests/check-126.-gen-PER.c
+19
-16
asn1c/tests/check-22.-fwide-types.c
asn1c/tests/check-22.-fwide-types.c
+1
-1
asn1c/tests/check-30.-fwide-types.c
asn1c/tests/check-30.-fwide-types.c
+1
-1
asn1c/tests/check-31.-fwide-types.c
asn1c/tests/check-31.-fwide-types.c
+1
-1
asn1c/tests/check-35.c
asn1c/tests/check-35.c
+31
-31
asn1c/tests/check-41.-fwide-types.c
asn1c/tests/check-41.-fwide-types.c
+27
-27
asn1c/tests/check-41.c
asn1c/tests/check-41.c
+1
-1
asn1c/tests/check-60.c
asn1c/tests/check-60.c
+4
-4
asn1c/tests/check-62.c
asn1c/tests/check-62.c
+8
-8
asn1c/tests/check-70.-fwide-types.c
asn1c/tests/check-70.-fwide-types.c
+13
-10
asn1c/tests/check-70.c
asn1c/tests/check-70.c
+10
-8
libasn1compiler/asn1c_constraint.c
libasn1compiler/asn1c_constraint.c
+2
-2
libasn1compiler/asn1c_misc.c
libasn1compiler/asn1c_misc.c
+1
-1
No files found.
asn1c/tests/check-119.-fwide-types.-gen-PER.c
View file @
5b63acf7
...
@@ -101,7 +101,7 @@ save_object_as(PDU_t *st, enum expectation exp, enum enctype how) {
...
@@ -101,7 +101,7 @@ save_object_as(PDU_t *st, enum expectation exp, enum enctype how) {
}
}
static
PDU_t
*
static
PDU_t
*
load_object_from
(
const
char
*
fname
,
enum
expectation
expectation
,
char
*
fbuf
,
size_t
size
,
enum
enctype
how
)
{
load_object_from
(
const
char
*
fname
,
enum
expectation
expectation
,
unsigned
char
*
fbuf
,
size_t
size
,
enum
enctype
how
)
{
asn_dec_rval_t
rval
;
asn_dec_rval_t
rval
;
PDU_t
*
st
=
0
;
PDU_t
*
st
=
0
;
size_t
csize
=
1
;
size_t
csize
=
1
;
...
@@ -158,6 +158,9 @@ load_object_from(const char *fname, enum expectation expectation, char *fbuf, si
...
@@ -158,6 +158,9 @@ load_object_from(const char *fname, enum expectation expectation, char *fbuf, si
rval
.
consumed
/=
8
;
rval
.
consumed
/=
8
;
}
}
break
;
break
;
case
AS_DER
:
case
AS_CXER
:
assert
(
!
"DER or CXER not supported for load"
);
}
}
fbuf_offset
+=
rval
.
consumed
;
fbuf_offset
+=
rval
.
consumed
;
fbuf_left
-=
rval
.
consumed
;
fbuf_left
-=
rval
.
consumed
;
...
@@ -172,12 +175,12 @@ load_object_from(const char *fname, enum expectation expectation, char *fbuf, si
...
@@ -172,12 +175,12 @@ load_object_from(const char *fname, enum expectation expectation, char *fbuf, si
if
(
how
==
AS_PER
)
{
if
(
how
==
AS_PER
)
{
fprintf
(
stderr
,
"[left %d, off %d, size %zd]
\n
"
,
fprintf
(
stderr
,
"[left %d, off %d, size %zd]
\n
"
,
fbuf_left
,
fbuf_offset
,
size
);
fbuf_left
,
fbuf_offset
,
size
);
assert
(
fbuf_offset
==
size
);
assert
(
fbuf_offset
==
(
ssize_t
)
size
);
}
else
{
}
else
{
assert
(
fbuf_offset
-
size
<
2
assert
(
fbuf_offset
-
size
<
2
||
(
fbuf_offset
+
1
/* "\n" */
==
size
||
(
fbuf_offset
+
1
/* "\n" */
==
(
ssize_t
)
size
&&
fbuf
[
size
-
1
]
==
'\n'
)
&&
fbuf
[
size
-
1
]
==
'\n'
)
||
(
fbuf_offset
+
2
/* "\r\n" */
==
size
||
(
fbuf_offset
+
2
/* "\r\n" */
==
(
ssize_t
)
size
&&
fbuf
[
size
-
2
]
==
'\r'
&&
fbuf
[
size
-
2
]
==
'\r'
&&
fbuf
[
size
-
1
]
==
'\n'
)
&&
fbuf
[
size
-
1
]
==
'\n'
)
);
);
...
@@ -227,7 +230,7 @@ xer_encoding_equal(char *obuf, size_t osize, char *nbuf, size_t nsize) {
...
@@ -227,7 +230,7 @@ xer_encoding_equal(char *obuf, size_t osize, char *nbuf, size_t nsize) {
}
}
static
void
static
void
process_XER_data
(
const
char
*
fname
,
enum
expectation
expectation
,
char
*
fbuf
,
size_t
size
)
{
process_XER_data
(
const
char
*
fname
,
enum
expectation
expectation
,
unsigned
char
*
fbuf
,
size_t
size
)
{
PDU_t
*
st
;
PDU_t
*
st
;
st
=
load_object_from
(
fname
,
expectation
,
fbuf
,
size
,
AS_XER
);
st
=
load_object_from
(
fname
,
expectation
,
fbuf
,
size
,
AS_XER
);
...
@@ -253,10 +256,10 @@ process_XER_data(const char *fname, enum expectation expectation, char *fbuf, si
...
@@ -253,10 +256,10 @@ process_XER_data(const char *fname, enum expectation expectation, char *fbuf, si
switch
(
expectation
)
{
switch
(
expectation
)
{
case
EXP_DIFFERENT
:
case
EXP_DIFFERENT
:
assert
(
!
xer_encoding_equal
(
fbuf
,
size
,
buf
,
buf_offset
));
assert
(
!
xer_encoding_equal
(
(
char
*
)
fbuf
,
size
,
(
char
*
)
buf
,
buf_offset
));
break
;
break
;
case
EXP_BROKEN
:
case
EXP_BROKEN
:
assert
(
!
xer_encoding_equal
(
fbuf
,
size
,
buf
,
buf_offset
));
assert
(
!
xer_encoding_equal
(
(
char
*
)
fbuf
,
size
,
(
char
*
)
buf
,
buf_offset
));
break
;
break
;
case
EXP_CXER_EXACT
:
case
EXP_CXER_EXACT
:
buf
[
buf_offset
++
]
=
'\n'
;
buf
[
buf_offset
++
]
=
'\n'
;
...
@@ -270,7 +273,7 @@ process_XER_data(const char *fname, enum expectation expectation, char *fbuf, si
...
@@ -270,7 +273,7 @@ process_XER_data(const char *fname, enum expectation expectation, char *fbuf, si
break
;
break
;
case
EXP_OK
:
case
EXP_OK
:
case
EXP_PER_NOCOMP
:
case
EXP_PER_NOCOMP
:
assert
(
xer_encoding_equal
(
fbuf
,
size
,
buf
,
buf_offset
));
assert
(
xer_encoding_equal
(
(
char
*
)
fbuf
,
size
,
(
char
*
)
buf
,
buf_offset
));
break
;
break
;
}
}
...
@@ -282,7 +285,7 @@ process_XER_data(const char *fname, enum expectation expectation, char *fbuf, si
...
@@ -282,7 +285,7 @@ process_XER_data(const char *fname, enum expectation expectation, char *fbuf, si
*/
*/
static
int
static
int
process
(
const
char
*
fname
)
{
process
(
const
char
*
fname
)
{
char
fbuf
[
4096
];
unsigned
char
fbuf
[
4096
];
char
*
ext
=
strrchr
(
fname
,
'.'
);
char
*
ext
=
strrchr
(
fname
,
'.'
);
enum
expectation
expectation
;
enum
expectation
expectation
;
int
rd
;
int
rd
;
...
@@ -308,14 +311,14 @@ process(const char *fname) {
...
@@ -308,14 +311,14 @@ process(const char *fname) {
fprintf
(
stderr
,
"
\n
Processing file [../%s]
\n
"
,
fname
);
fprintf
(
stderr
,
"
\n
Processing file [../%s]
\n
"
,
fname
);
snprintf
(
fbuf
,
sizeof
(
fbuf
),
"../data-119/%s"
,
fname
);
snprintf
(
(
char
*
)
fbuf
,
sizeof
(
fbuf
),
"../data-119/%s"
,
fname
);
fp
=
fopen
(
fbuf
,
"r"
);
fp
=
fopen
(
(
char
*
)
fbuf
,
"r"
);
assert
(
fp
);
assert
(
fp
);
rd
=
fread
(
fbuf
,
1
,
sizeof
(
fbuf
),
fp
);
rd
=
fread
(
fbuf
,
1
,
sizeof
(
fbuf
),
fp
);
fclose
(
fp
);
fclose
(
fp
);
assert
(
rd
<
sizeof
(
fbuf
));
/* expect small files */
assert
(
rd
<
(
ssize_t
)
sizeof
(
fbuf
));
/* expect small files */
process_XER_data
(
fname
,
expectation
,
fbuf
,
rd
);
process_XER_data
(
fname
,
expectation
,
fbuf
,
rd
);
...
...
asn1c/tests/check-119.-gen-PER.c
View file @
5b63acf7
...
@@ -101,7 +101,7 @@ save_object_as(PDU_t *st, enum expectation exp, enum enctype how) {
...
@@ -101,7 +101,7 @@ save_object_as(PDU_t *st, enum expectation exp, enum enctype how) {
}
}
static
PDU_t
*
static
PDU_t
*
load_object_from
(
const
char
*
fname
,
enum
expectation
expectation
,
char
*
fbuf
,
size_t
size
,
enum
enctype
how
)
{
load_object_from
(
const
char
*
fname
,
enum
expectation
expectation
,
unsigned
char
*
fbuf
,
size_t
size
,
enum
enctype
how
)
{
asn_dec_rval_t
rval
;
asn_dec_rval_t
rval
;
PDU_t
*
st
=
0
;
PDU_t
*
st
=
0
;
size_t
csize
=
1
;
size_t
csize
=
1
;
...
@@ -158,6 +158,9 @@ load_object_from(const char *fname, enum expectation expectation, char *fbuf, si
...
@@ -158,6 +158,9 @@ load_object_from(const char *fname, enum expectation expectation, char *fbuf, si
rval
.
consumed
/=
8
;
rval
.
consumed
/=
8
;
}
}
break
;
break
;
case
AS_DER
:
case
AS_CXER
:
assert
(
!
"Unexpected DER or CXER load request"
);
}
}
fbuf_offset
+=
rval
.
consumed
;
fbuf_offset
+=
rval
.
consumed
;
fbuf_left
-=
rval
.
consumed
;
fbuf_left
-=
rval
.
consumed
;
...
@@ -172,12 +175,12 @@ load_object_from(const char *fname, enum expectation expectation, char *fbuf, si
...
@@ -172,12 +175,12 @@ load_object_from(const char *fname, enum expectation expectation, char *fbuf, si
if
(
how
==
AS_PER
)
{
if
(
how
==
AS_PER
)
{
fprintf
(
stderr
,
"[left %d, off %d, size %zd]
\n
"
,
fprintf
(
stderr
,
"[left %d, off %d, size %zd]
\n
"
,
fbuf_left
,
fbuf_offset
,
size
);
fbuf_left
,
fbuf_offset
,
size
);
assert
(
fbuf_offset
==
size
);
assert
(
fbuf_offset
==
(
ssize_t
)
size
);
}
else
{
}
else
{
assert
(
fbuf_offset
-
size
<
2
assert
(
fbuf_offset
-
size
<
2
||
(
fbuf_offset
+
1
/* "\n" */
==
size
||
(
fbuf_offset
+
1
/* "\n" */
==
(
ssize_t
)
size
&&
fbuf
[
size
-
1
]
==
'\n'
)
&&
fbuf
[
size
-
1
]
==
'\n'
)
||
(
fbuf_offset
+
2
/* "\r\n" */
==
size
||
(
fbuf_offset
+
2
/* "\r\n" */
==
(
ssize_t
)
size
&&
fbuf
[
size
-
2
]
==
'\r'
&&
fbuf
[
size
-
2
]
==
'\r'
&&
fbuf
[
size
-
1
]
==
'\n'
)
&&
fbuf
[
size
-
1
]
==
'\n'
)
);
);
...
@@ -195,7 +198,9 @@ load_object_from(const char *fname, enum expectation expectation, char *fbuf, si
...
@@ -195,7 +198,9 @@ load_object_from(const char *fname, enum expectation expectation, char *fbuf, si
}
}
static
int
static
int
xer_encoding_equal
(
char
*
obuf
,
size_t
osize
,
char
*
nbuf
,
size_t
nsize
)
{
xer_encoding_equal
(
void
*
obufp
,
size_t
osize
,
void
*
nbufp
,
size_t
nsize
)
{
char
*
obuf
=
obufp
;
char
*
nbuf
=
nbufp
;
char
*
oend
=
obuf
+
osize
;
char
*
oend
=
obuf
+
osize
;
char
*
nend
=
nbuf
+
nsize
;
char
*
nend
=
nbuf
+
nsize
;
...
@@ -227,7 +232,7 @@ xer_encoding_equal(char *obuf, size_t osize, char *nbuf, size_t nsize) {
...
@@ -227,7 +232,7 @@ xer_encoding_equal(char *obuf, size_t osize, char *nbuf, size_t nsize) {
}
}
static
void
static
void
process_XER_data
(
const
char
*
fname
,
enum
expectation
expectation
,
char
*
fbuf
,
ssize_t
size
)
{
process_XER_data
(
const
char
*
fname
,
enum
expectation
expectation
,
unsigned
char
*
fbuf
,
ssize_t
size
)
{
PDU_t
*
st
;
PDU_t
*
st
;
st
=
load_object_from
(
fname
,
expectation
,
fbuf
,
size
,
AS_XER
);
st
=
load_object_from
(
fname
,
expectation
,
fbuf
,
size
,
AS_XER
);
...
@@ -260,12 +265,12 @@ process_XER_data(const char *fname, enum expectation expectation, char *fbuf, ss
...
@@ -260,12 +265,12 @@ process_XER_data(const char *fname, enum expectation expectation, char *fbuf, ss
break
;
break
;
case
EXP_CXER_EXACT
:
case
EXP_CXER_EXACT
:
buf
[
buf_offset
++
]
=
'\n'
;
buf
[
buf_offset
++
]
=
'\n'
;
assert
(
size
==
buf_offset
);
assert
(
(
ssize_t
)
size
==
(
ssize_t
)
buf_offset
);
assert
(
memcmp
(
fbuf
,
buf
,
size
)
==
0
);
assert
(
memcmp
(
fbuf
,
buf
,
size
)
==
0
);
break
;
break
;
case
EXP_CXER_DIFF
:
case
EXP_CXER_DIFF
:
buf
[
buf_offset
++
]
=
'\n'
;
buf
[
buf_offset
++
]
=
'\n'
;
assert
(
size
!=
buf_offset
assert
(
(
ssize_t
)
size
!=
(
ssize_t
)
buf_offset
||
memcmp
(
fbuf
,
buf
,
size
));
||
memcmp
(
fbuf
,
buf
,
size
));
break
;
break
;
case
EXP_OK
:
case
EXP_OK
:
...
@@ -282,7 +287,7 @@ process_XER_data(const char *fname, enum expectation expectation, char *fbuf, ss
...
@@ -282,7 +287,7 @@ process_XER_data(const char *fname, enum expectation expectation, char *fbuf, ss
*/
*/
static
int
static
int
process
(
const
char
*
fname
)
{
process
(
const
char
*
fname
)
{
char
fbuf
[
4096
];
unsigned
char
fbuf
[
4096
];
char
*
ext
=
strrchr
(
fname
,
'.'
);
char
*
ext
=
strrchr
(
fname
,
'.'
);
enum
expectation
expectation
;
enum
expectation
expectation
;
int
rd
;
int
rd
;
...
@@ -308,14 +313,14 @@ process(const char *fname) {
...
@@ -308,14 +313,14 @@ process(const char *fname) {
fprintf
(
stderr
,
"
\n
Processing file [../%s]
\n
"
,
fname
);
fprintf
(
stderr
,
"
\n
Processing file [../%s]
\n
"
,
fname
);
snprintf
(
fbuf
,
sizeof
(
fbuf
),
"../data-119/%s"
,
fname
);
snprintf
(
(
char
*
)
fbuf
,
sizeof
(
fbuf
),
"../data-119/%s"
,
fname
);
fp
=
fopen
(
fbuf
,
"r"
);
fp
=
fopen
(
(
char
*
)
fbuf
,
"r"
);
assert
(
fp
);
assert
(
fp
);
rd
=
fread
(
fbuf
,
1
,
sizeof
(
fbuf
),
fp
);
rd
=
fread
(
fbuf
,
1
,
sizeof
(
fbuf
),
fp
);
fclose
(
fp
);
fclose
(
fp
);
assert
(
rd
<
sizeof
(
fbuf
));
/* expect small files */
assert
(
rd
<
(
ssize_t
)
sizeof
(
fbuf
));
/* expect small files */
process_XER_data
(
fname
,
expectation
,
fbuf
,
rd
);
process_XER_data
(
fname
,
expectation
,
fbuf
,
rd
);
...
...
asn1c/tests/check-126.-gen-PER.c
View file @
5b63acf7
...
@@ -82,7 +82,7 @@ save_object_as(PDU_t *st, enum enctype how) {
...
@@ -82,7 +82,7 @@ save_object_as(PDU_t *st, enum enctype how) {
}
}
static
PDU_t
*
static
PDU_t
*
load_object_from
(
const
char
*
fname
,
char
*
fbuf
,
size_t
size
,
enum
enctype
how
,
int
mustfail
)
{
load_object_from
(
const
char
*
fname
,
unsigned
char
*
fbuf
,
size_t
size
,
enum
enctype
how
,
int
mustfail
)
{
asn_dec_rval_t
rval
;
asn_dec_rval_t
rval
;
PDU_t
*
st
=
0
;
PDU_t
*
st
=
0
;
ssize_t
csize
=
1
;
ssize_t
csize
=
1
;
...
@@ -176,12 +176,12 @@ load_object_from(const char *fname, char *fbuf, size_t size, enum enctype how, i
...
@@ -176,12 +176,12 @@ load_object_from(const char *fname, char *fbuf, size_t size, enum enctype how, i
if
(
how
==
AS_PER
)
{
if
(
how
==
AS_PER
)
{
fprintf
(
stderr
,
"[left %d, off %d, size %zd]
\n
"
,
fprintf
(
stderr
,
"[left %d, off %d, size %zd]
\n
"
,
fbuf_left
,
fbuf_offset
,
size
);
fbuf_left
,
fbuf_offset
,
size
);
assert
(
fbuf_offset
==
size
);
assert
(
fbuf_offset
==
(
ssize_t
)
size
);
}
else
{
}
else
{
assert
(
fbuf_offset
-
size
<
2
assert
(
fbuf_offset
-
size
<
2
||
(
fbuf_offset
+
1
/* "\n" */
==
size
||
(
fbuf_offset
+
1
/* "\n" */
==
(
ssize_t
)
size
&&
fbuf
[
size
-
1
]
==
'\n'
)
&&
fbuf
[
size
-
1
]
==
'\n'
)
||
(
fbuf_offset
+
2
/* "\r\n" */
==
size
||
(
fbuf_offset
+
2
/* "\r\n" */
==
(
ssize_t
)
size
&&
fbuf
[
size
-
2
]
==
'\r'
&&
fbuf
[
size
-
2
]
==
'\r'
&&
fbuf
[
size
-
1
]
==
'\n'
)
&&
fbuf
[
size
-
1
]
==
'\n'
)
);
);
...
@@ -193,7 +193,9 @@ load_object_from(const char *fname, char *fbuf, size_t size, enum enctype how, i
...
@@ -193,7 +193,9 @@ load_object_from(const char *fname, char *fbuf, size_t size, enum enctype how, i
}
}
static
int
static
int
xer_encoding_equal
(
char
*
obuf
,
size_t
osize
,
char
*
nbuf
,
size_t
nsize
)
{
xer_encoding_equal
(
void
*
obufp
,
size_t
osize
,
void
*
nbufp
,
size_t
nsize
)
{
char
*
obuf
=
obufp
;
char
*
nbuf
=
nbufp
;
char
*
oend
=
obuf
+
osize
;
char
*
oend
=
obuf
+
osize
;
char
*
nend
=
nbuf
+
nsize
;
char
*
nend
=
nbuf
+
nsize
;
...
@@ -225,9 +227,10 @@ xer_encoding_equal(char *obuf, size_t osize, char *nbuf, size_t nsize) {
...
@@ -225,9 +227,10 @@ xer_encoding_equal(char *obuf, size_t osize, char *nbuf, size_t nsize) {
}
}
static
void
static
void
compare_with_data_out
(
const
char
*
fname
,
char
*
buf
,
size_t
size
)
{
compare_with_data_out
(
const
char
*
fname
,
void
*
datap
,
size_t
size
)
{
char
*
data
=
datap
;
char
outName
[
256
];
char
outName
[
256
];
char
fbuf
[
1024
];
unsigned
char
fbuf
[
1024
];
size_t
rd
;
size_t
rd
;
FILE
*
f
;
FILE
*
f
;
char
lastChar
;
char
lastChar
;
...
@@ -244,7 +247,7 @@ compare_with_data_out(const char *fname, char *buf, size_t size) {
...
@@ -244,7 +247,7 @@ compare_with_data_out(const char *fname, char *buf, size_t size) {
if
((
compare
&&
!
mustfail
)
&&
getenv
(
"REGENERATE"
))
{
if
((
compare
&&
!
mustfail
)
&&
getenv
(
"REGENERATE"
))
{
f
=
fopen
(
outName
,
"w"
);
f
=
fopen
(
outName
,
"w"
);
fwrite
(
buf
,
1
,
size
,
f
);
fwrite
(
data
,
1
,
size
,
f
);
fclose
(
f
);
fclose
(
f
);
}
else
{
}
else
{
f
=
fopen
(
outName
,
"r"
);
f
=
fopen
(
outName
,
"r"
);
...
@@ -259,17 +262,17 @@ compare_with_data_out(const char *fname, char *buf, size_t size) {
...
@@ -259,17 +262,17 @@ compare_with_data_out(const char *fname, char *buf, size_t size) {
if
(
compare
)
{
if
(
compare
)
{
assert
(
rd
==
(
size_t
)
size
);
assert
(
rd
==
(
size_t
)
size
);
assert
(
memcmp
(
fbuf
,
buf
,
rd
)
==
0
);
assert
(
memcmp
(
fbuf
,
data
,
rd
)
==
0
);
fprintf
(
stderr
,
"XER->PER recoding .in->.out match.
\n
"
);
fprintf
(
stderr
,
"XER->PER recoding .in->.out match.
\n
"
);
}
else
{
}
else
{
assert
(
rd
!=
(
size_t
)
size
||
memcmp
(
fbuf
,
buf
,
rd
));
assert
(
rd
!=
(
size_t
)
size
||
memcmp
(
fbuf
,
data
,
rd
));
fprintf
(
stderr
,
"XER->PER recoding .in->.out diverge.
\n
"
);
fprintf
(
stderr
,
"XER->PER recoding .in->.out diverge.
\n
"
);
}
}
}
}
}
}
static
void
static
void
process_XER_data
(
const
char
*
fname
,
char
*
fbuf
,
size_t
size
)
{
process_XER_data
(
const
char
*
fname
,
unsigned
char
*
fbuf
,
size_t
size
)
{
PDU_t
*
st
;
PDU_t
*
st
;
st
=
load_object_from
(
fname
,
fbuf
,
size
,
AS_XER
,
0
);
st
=
load_object_from
(
fname
,
fbuf
,
size
,
AS_XER
,
0
);
...
@@ -289,9 +292,9 @@ process_XER_data(const char *fname, char *fbuf, size_t size) {
...
@@ -289,9 +292,9 @@ process_XER_data(const char *fname, char *fbuf, size_t size) {
fprintf
(
stderr
,
"=== end ===
\n
"
);
fprintf
(
stderr
,
"=== end ===
\n
"
);
if
(
fname
[
strlen
(
fname
)
-
4
]
==
'X'
)
if
(
fname
[
strlen
(
fname
)
-
4
]
==
'X'
)
assert
(
!
xer_encoding_equal
(
fbuf
,
size
,
buf
,
buf_offset
));
assert
(
!
xer_encoding_equal
(
(
char
*
)
fbuf
,
size
,
(
char
*
)
buf
,
buf_offset
));
else
else
assert
(
xer_encoding_equal
(
fbuf
,
size
,
buf
,
buf_offset
));
assert
(
xer_encoding_equal
(
(
char
*
)
fbuf
,
size
,
(
char
*
)
buf
,
buf_offset
));
asn_DEF_PDU
.
free_struct
(
&
asn_DEF_PDU
,
st
,
0
);
asn_DEF_PDU
.
free_struct
(
&
asn_DEF_PDU
,
st
,
0
);
}
}
...
@@ -301,7 +304,7 @@ process_XER_data(const char *fname, char *fbuf, size_t size) {
...
@@ -301,7 +304,7 @@ process_XER_data(const char *fname, char *fbuf, size_t size) {
*/
*/
static
int
static
int
process
(
const
char
*
fname
)
{
process
(
const
char
*
fname
)
{
char
fbuf
[
4096
];
unsigned
char
fbuf
[
4096
];
char
*
ext
=
strrchr
(
fname
,
'.'
);
char
*
ext
=
strrchr
(
fname
,
'.'
);
int
rd
;
int
rd
;
FILE
*
fp
;
FILE
*
fp
;
...
@@ -311,8 +314,8 @@ process(const char *fname) {
...
@@ -311,8 +314,8 @@ process(const char *fname) {
fprintf
(
stderr
,
"
\n
Processing file [../%s]
\n
"
,
fname
);
fprintf
(
stderr
,
"
\n
Processing file [../%s]
\n
"
,
fname
);
snprintf
(
fbuf
,
sizeof
(
fbuf
),
"../data-126/%s"
,
fname
);
snprintf
(
(
char
*
)
fbuf
,
sizeof
(
fbuf
),
"../data-126/%s"
,
fname
);
fp
=
fopen
(
fbuf
,
"r"
);
fp
=
fopen
(
(
char
*
)
fbuf
,
"r"
);
assert
(
fp
);
assert
(
fp
);
rd
=
fread
(
fbuf
,
1
,
sizeof
(
fbuf
),
fp
);
rd
=
fread
(
fbuf
,
1
,
sizeof
(
fbuf
),
fp
);
...
...
asn1c/tests/check-22.-fwide-types.c
View file @
5b63acf7
...
@@ -93,7 +93,7 @@ check(int is_ok, uint8_t *buf, size_t size, size_t consumed) {
...
@@ -93,7 +93,7 @@ check(int is_ok, uint8_t *buf, size_t size, size_t consumed) {
if
(
erval
.
encoded
!=
sizeof
(
buf1
))
{
if
(
erval
.
encoded
!=
sizeof
(
buf1
))
{
printf
(
"%d != %d
\n
"
,
(
int
)
erval
.
encoded
,
(
int
)
sizeof
(
buf1
));
printf
(
"%d != %d
\n
"
,
(
int
)
erval
.
encoded
,
(
int
)
sizeof
(
buf1
));
}
}
assert
(
erval
.
encoded
==
sizeof
(
buf1
));
assert
(
erval
.
encoded
==
(
ssize_t
)
sizeof
(
buf1
));
for
(
i
=
0
;
i
<
(
ssize_t
)
sizeof
(
buf1
);
i
++
)
{
for
(
i
=
0
;
i
<
(
ssize_t
)
sizeof
(
buf1
);
i
++
)
{
if
(
buf1
[
i
]
!=
buf2
[
i
])
{
if
(
buf1
[
i
]
!=
buf2
[
i
])
{
fprintf
(
stderr
,
"Recreated buffer content mismatch:
\n
"
);
fprintf
(
stderr
,
"Recreated buffer content mismatch:
\n
"
);
...
...
asn1c/tests/check-30.-fwide-types.c
View file @
5b63acf7
...
@@ -162,7 +162,7 @@ check(int is_ok, uint8_t *buf, size_t size, size_t consumed) {
...
@@ -162,7 +162,7 @@ check(int is_ok, uint8_t *buf, size_t size, size_t consumed) {
assert
(
t
.
i
.
size
==
1
);
assert
(
t
.
i
.
size
==
1
);
assert
(
t
.
i
.
buf
[
0
]
==
96
);
assert
(
t
.
i
.
buf
[
0
]
==
96
);
assert
(
t
.
s
.
size
==
3
);
assert
(
t
.
s
.
size
==
3
);
assert
(
strcmp
(
t
.
s
.
buf
,
"xyz"
)
==
0
);
assert
(
strcmp
(
(
char
*
)
t
.
s
.
buf
,
"xyz"
)
==
0
);
if
(
buf
==
buf3
)
{
if
(
buf
==
buf3
)
{
assert
(
t
.
b
);
assert
(
t
.
b
);
}
else
{
}
else
{
...
...
asn1c/tests/check-31.-fwide-types.c
View file @
5b63acf7
...
@@ -133,7 +133,7 @@ check(int is_ok, uint8_t *buf, size_t size, size_t consumed) {
...
@@ -133,7 +133,7 @@ check(int is_ok, uint8_t *buf, size_t size, size_t consumed) {
buf_pos
=
0
;
buf_pos
=
0
;
der_encode
(
&
asn_DEF_Forest
,
&
t
,
der_encode
(
&
asn_DEF_Forest
,
&
t
,
bytes_compare
,
buf1_reconstr
);
bytes_compare
,
buf1_reconstr
);
assert
(
buf_pos
==
sizeof
(
buf1_reconstr
));
assert
(
buf_pos
==
(
ssize_t
)
sizeof
(
buf1_reconstr
));
asn_fprint
(
stderr
,
&
asn_DEF_Forest
,
&
t
);
asn_fprint
(
stderr
,
&
asn_DEF_Forest
,
&
t
);
xer_fprint
(
stderr
,
&
asn_DEF_Forest
,
&
t
);
xer_fprint
(
stderr
,
&
asn_DEF_Forest
,
&
t
);
...
...
asn1c/tests/check-35.c
View file @
5b63acf7
...
@@ -136,9 +136,9 @@ check(T_t *tp, uint8_t *buf, size_t size, size_t consumed) {
...
@@ -136,9 +136,9 @@ check(T_t *tp, uint8_t *buf, size_t size, size_t consumed) {
assert
(
rval
.
code
==
RC_OK
);
assert
(
rval
.
code
==
RC_OK
);
assert
(
rval
.
consumed
==
consumed
);
assert
(
rval
.
consumed
==
consumed
);
assert
(
strcmp
(
tp
->
a
.
buf
,
"=<&>"
)
==
0
);
assert
(
strcmp
(
(
char
*
)
tp
->
a
.
buf
,
"=<&>"
)
==
0
);
assert
(
strcmp
(
tp
->
b
.
choice
.
b1
.
buf
,
"z"
)
==
0
assert
(
strcmp
(
(
char
*
)
tp
->
b
.
choice
.
b1
.
buf
,
"z"
)
==
0
&&
strcmp
(
tp
->
b
.
choice
.
b2
.
buf
,
"z"
)
==
0
);
&&
strcmp
(
(
char
*
)
tp
->
b
.
choice
.
b2
.
buf
,
"z"
)
==
0
);
asn_fprint
(
stderr
,
&
asn_DEF_T
,
tp
);
asn_fprint
(
stderr
,
&
asn_DEF_T
,
tp
);
xer_fprint
(
stderr
,
&
asn_DEF_T
,
tp
);
xer_fprint
(
stderr
,
&
asn_DEF_T
,
tp
);
...
@@ -169,7 +169,7 @@ buf_fill(const void *buffer, size_t size, void *app_key) {
...
@@ -169,7 +169,7 @@ buf_fill(const void *buffer, size_t size, void *app_key) {
static
void
static
void
compare
(
T_t
*
tp
,
uint8_t
*
cmp_buf
,
size_t
cmp_buf_size
)
{
compare
(
T_t
*
tp
,
uint8_t
*
cmp_buf
,
size_t
cmp_buf_size
)
{
asn_enc_rval_t
erval
;
asn_enc_rval_t
erval
;
in
t
i
;
size_
t
i
;
buf_size
=
cmp_buf_size
+
100
;
buf_size
=
cmp_buf_size
+
100
;
buf
=
alloca
(
buf_size
);
buf
=
alloca
(
buf_size
);
...
@@ -180,15 +180,15 @@ compare(T_t *tp, uint8_t *cmp_buf, size_t cmp_buf_size) {
...
@@ -180,15 +180,15 @@ compare(T_t *tp, uint8_t *cmp_buf, size_t cmp_buf_size) {
*/
*/
erval
=
der_encode
(
&
asn_DEF_T
,
tp
,
buf_fill
,
0
);
erval
=
der_encode
(
&
asn_DEF_T
,
tp
,
buf_fill
,
0
);
assert
(
erval
.
encoded
!=
-
1
);
assert
(
erval
.
encoded
!=
-
1
);
if
(
erval
.
encoded
!=
cmp_buf_size
)
{
if
(
erval
.
encoded
!=
(
ssize_t
)
cmp_buf_size
)
{
printf
(
"%zd != %zd
\n
"
,
erval
.
encoded
,
cmp_buf_size
);
printf
(
"%zd != %zd
\n
"
,
erval
.
encoded
,
cmp_buf_size
);
}
}
assert
(
erval
.
encoded
==
cmp_buf_size
);
assert
(
erval
.
encoded
==
(
ssize_t
)
cmp_buf_size
);
for
(
i
=
0
;
i
<
cmp_buf_size
;
i
++
)
{
for
(
i
=
0
;
i
<
cmp_buf_size
;
i
++
)
{
if
(
buf
[
i
]
!=
cmp_buf
[
i
])
{
if
(
buf
[
i
]
!=
cmp_buf
[
i
])
{
fprintf
(
stderr
,
"Recreated buffer content mismatch:
\n
"
);
fprintf
(
stderr
,
"Recreated buffer content mismatch:
\n
"
);
fprintf
(
stderr
,
"Byte %d, %x != %x (%d != %d)
\n
"
,
fprintf
(
stderr
,
"Byte %d, %x != %x (%d != %d)
\n
"
,
i
,
(
int
)
i
,
buf
[
i
],
cmp_buf
[
i
],
buf
[
i
],
cmp_buf
[
i
],
buf
[
i
],
cmp_buf
[
i
]
buf
[
i
],
cmp_buf
[
i
]
);
);
...
@@ -198,70 +198,70 @@ compare(T_t *tp, uint8_t *cmp_buf, size_t cmp_buf_size) {
...
@@ -198,70 +198,70 @@ compare(T_t *tp, uint8_t *cmp_buf, size_t cmp_buf_size) {
}
}
static
void
static
void
partial_read
(
uint8_t
*
buf
,
size_t
size
)
{
partial_read
(
uint8_t
*
data
,
size_t
size
)
{
T_t
t
,
*
tp
;
T_t
t
,
*
tp
;
asn_dec_rval_t
rval
;
asn_dec_rval_t
rval
;
size_t
i1
,
i2
;
size_t
i1
,
i2
;
uint8_t
*
buf
1
=
alloca
(
size
);
uint8_t
*
data
1
=
alloca
(
size
);
uint8_t
*
buf
2
=
alloca
(
size
);
uint8_t
*
data
2
=
alloca
(
size
);
uint8_t
*
buf
3
=
alloca
(
size
);
uint8_t
*
data
3
=
alloca
(
size
);
fprintf
(
stderr
,
"
\n
Partial read sequence...
\n
"
);
fprintf
(
stderr
,
"
\n
Partial read sequence...
\n
"
);
/*
/*
* Divide the space (size) into three blocks in various combinations:
* Divide the space (size) into three blocks in various combinations:
* |<----->i1<----->i2<----->|
* |<----->i1<----->i2<----->|
* ^
buf ^ buf
+size
* ^
data ^ data
+size
* Try to read block by block.
* Try to read block by block.
*/
*/
for
(
i1
=
0
;
i1
<
size
;
i1
++
)
{
for
(
i1
=
0
;
i1
<
size
;
i1
++
)
{
for
(
i2
=
i1
;
i2
<
size
;
i2
++
)
{
for
(
i2
=
i1
;
i2
<
size
;
i2
++
)
{
uint8_t
*
chunk1
=
buf
;
uint8_t
*
chunk1
=
data
;
size_t
size1
=
i1
;
size_t
size1
=
i1
;
uint8_t
*
chunk2
=
buf
+
size1
;
uint8_t
*
chunk2
=
data
+
size1
;
size_t
size2
=
i2
-
i1
;
size_t
size2
=
i2
-
i1
;
uint8_t
*
chunk3
=
buf
+
size1
+
size2
;
uint8_t
*
chunk3
=
data
+
size1
+
size2
;
size_t
size3
=
size
-
size1
-
size2
;
size_t
size3
=
size
-
size1
-
size2
;
fprintf
(
stderr
,
"
\n
%zd:{%zd, %zd, %zd}...
\n
"
,
fprintf
(
stderr
,
"
\n
%zd:{%zd, %zd, %zd}...
\n
"
,
size
,
size1
,
size2
,
size3
);
size
,
size1
,
size2
,
size3
);
memset
(
buf
1
,
0
,
size
);
memset
(
data
1
,
0
,
size
);
memset
(
buf
2
,
0
,
size
);
memset
(
data
2
,
0
,
size
);
memset
(
buf
3
,
0
,
size
);
memset
(
data
3
,
0
,
size
);
memcpy
(
buf
1
,
chunk1
,
size1
);
memcpy
(
data
1
,
chunk1
,
size1
);
memcpy
(
buf
2
,
chunk2
,
size2
);
memcpy
(
data
2
,
chunk2
,
size2
);
memcpy
(
buf
3
,
chunk3
,
size3
);
memcpy
(
data
3
,
chunk3
,
size3
);
tp
=
memset
(
&
t
,
0
,
sizeof
(
t
));
tp
=
memset
(
&
t
,
0
,
sizeof
(
t
));
fprintf
(
stderr
,
"=> Chunk 1 (%zd):
\n
"
,
size1
);
fprintf
(
stderr
,
"=> Chunk 1 (%zd):
\n
"
,
size1
);
rval
=
ber_decode
(
0
,
&
asn_DEF_T
,
(
void
**
)
&
tp
,
rval
=
ber_decode
(
0
,
&
asn_DEF_T
,
(
void
**
)
&
tp
,
buf
1
,
size1
);
data
1
,
size1
);
assert
(
rval
.
code
==
RC_WMORE
);
assert
(
rval
.
code
==
RC_WMORE
);
assert
(
rval
.
consumed
<=
size1
);
assert
(
rval
.
consumed
<=
size1
);
if
(
rval
.
consumed
<
size1
)
{
if
(
rval
.
consumed
<
size1
)
{
int
leftover
=
size1
-
rval
.
consumed
;
int
leftover
=
size1
-
rval
.
consumed
;
memcpy
(
buf2
,
buf
1
+
rval
.
consumed
,
leftover
);
memcpy
(
data2
,
data
1
+
rval
.
consumed
,
leftover
);
memcpy
(
buf
2
+
leftover
,
chunk2
,
size2
);
memcpy
(
data
2
+
leftover
,
chunk2
,
size2
);
size2
+=
leftover
;
size2
+=
leftover
;
}
}
fprintf
(
stderr
,
"=> Chunk 2 (%zd):
\n
"
,
size2
);
fprintf
(
stderr
,
"=> Chunk 2 (%zd):
\n
"
,
size2
);
rval
=
ber_decode
(
0
,
&
asn_DEF_T
,
(
void
**
)
&
tp
,
rval
=
ber_decode
(
0
,
&
asn_DEF_T
,
(
void
**
)
&
tp
,
buf
2
,
size2
);
data
2
,
size2
);
assert
(
rval
.
code
==
RC_WMORE
);
assert
(
rval
.
code
==
RC_WMORE
);
assert
(
rval
.
consumed
<=
size2
);
assert
(
rval
.
consumed
<=
size2
);
if
(
rval
.
consumed
<
size2
)
{
if
(
rval
.
consumed
<
size2
)
{
int
leftover
=
size2
-
rval
.
consumed
;
int
leftover
=
size2
-
rval
.
consumed
;
memcpy
(
buf3
,
buf
2
+
rval
.
consumed
,
leftover
);
memcpy
(
data3
,
data
2
+
rval
.
consumed
,
leftover
);
memcpy
(
buf
3
+
leftover
,
chunk3
,
size3
);
memcpy
(
data
3
+
leftover
,
chunk3
,
size3
);
size3
+=
leftover
;
size3
+=
leftover
;
}
}
fprintf
(
stderr
,
"=> Chunk 3 (%zd):
\n
"
,
size3
);
fprintf
(
stderr
,
"=> Chunk 3 (%zd):
\n
"
,
size3
);
rval
=
ber_decode
(
0
,
&
asn_DEF_T
,
(
void
**
)
&
tp
,
rval
=
ber_decode
(
0
,
&
asn_DEF_T
,
(
void
**
)
&
tp
,
buf
3
,
size3
);
data
3
,
size3
);
assert
(
rval
.
code
==
RC_OK
);
assert
(
rval
.
code
==
RC_OK
);
assert
(
rval
.
consumed
==
size3
);
assert
(
rval
.
consumed
==
size3
);
...
@@ -283,13 +283,13 @@ xer_cb(const void *buffer, size_t size, void *key) {
...
@@ -283,13 +283,13 @@ xer_cb(const void *buffer, size_t size, void *key) {
}
}
static
void
static
void
check_xer
(
uint8_t
*
buf
,
uint8_t
size
,
char
*
xer_sample
)
{
check_xer
(
uint8_t
*
data
,
uint8_t
size
,
char
*
xer_sample
)
{
T_t
*
tp
=
0
;
T_t
*
tp
=
0
;
asn_dec_rval_t
rval
;
asn_dec_rval_t
rval
;
asn_enc_rval_t
er
;
asn_enc_rval_t
er
;
size_t
xer_sample_len
=
strlen
(
xer_sample
);
size_t
xer_sample_len
=
strlen
(
xer_sample
);
rval
=
ber_decode
(
0
,
&
asn_DEF_T
,
(
void
**
)
&
tp
,
buf
,
size
);
rval
=
ber_decode
(
0
,
&
asn_DEF_T
,
(
void
**
)
&
tp
,
data
,
size
);
assert
(
rval
.
code
==
RC_OK
);
assert
(
rval
.
code
==
RC_OK
);
assert
(
rval
.
consumed
==
size
);
assert
(
rval
.
consumed
==
size
);
assert
(
tp
);
assert
(
tp
);
...
@@ -300,7 +300,7 @@ check_xer(uint8_t *buf, uint8_t size, char *xer_sample) {
...
@@ -300,7 +300,7 @@ check_xer(uint8_t *buf, uint8_t size, char *xer_sample) {
xer_buf
[
xer_off
]
=
0
;
xer_buf
[
xer_off
]
=
0
;
printf
(
"[%s] (%zd/%zd) vs [%s] (%zd)
\n
"
,
printf
(
"[%s] (%zd/%zd) vs [%s] (%zd)
\n
"
,
xer_buf
,
er
.
encoded
,
xer_off
,
xer_sample
,
xer_sample_len
);
xer_buf
,
er
.
encoded
,
xer_off
,
xer_sample
,
xer_sample_len
);
assert
(
er
.
encoded
==
xer_off
);
assert
(
er
.
encoded
==
(
ssize_t
)
xer_off
);
assert
(
xer_off
==
xer_sample_len
);
assert
(
xer_off
==
xer_sample_len
);
assert
(
memcmp
(
xer_buf
,
xer_sample
,
xer_off
)
==
0
);
assert
(
memcmp
(
xer_buf
,
xer_sample
,
xer_off
)
==
0
);
}
}
...
...
asn1c/tests/check-41.-fwide-types.c
View file @
5b63acf7
...
@@ -155,8 +155,8 @@ check(T_t *tp, uint8_t *buf, size_t size, size_t consumed) {
...
@@ -155,8 +155,8 @@ check(T_t *tp, uint8_t *buf, size_t size, size_t consumed) {
/*
/*
assert(tp->string.size == 128);
assert(tp->string.size == 128);
assert(strncmp(tp->string.buf, "zz") == 0);
assert(strncmp(tp->string.buf, "zz") == 0);
assert(strcmp(tp->b.choice.b1.buf, "z") == 0
assert(strcmp(
(char *)
tp->b.choice.b1.buf, "z") == 0
&& strcmp(tp->b.choice.b2.buf, "z") == 0);
&& strcmp(
(char *)
tp->b.choice.b2.buf, "z") == 0);
*/
*/
}
}
...
@@ -185,7 +185,7 @@ buf_fill(const void *bufp, size_t size, void *app_key) {
...
@@ -185,7 +185,7 @@ buf_fill(const void *bufp, size_t size, void *app_key) {
static
void
static
void
compare
(
T_t
*
tp
,
uint8_t
*
cmp_buf
,
size_t
cmp_buf_size
)
{
compare
(
T_t
*
tp
,
uint8_t
*
cmp_buf
,
size_t
cmp_buf_size
)
{
asn_enc_rval_t
erval
;
asn_enc_rval_t
erval
;
in
t
i
;
size_
t
i
;
buf_size
=
cmp_buf_size
+
100
;
buf_size
=
cmp_buf_size
+
100
;
buffer
=
alloca
(
buf_size
);
buffer
=
alloca
(
buf_size
);
...
@@ -196,15 +196,15 @@ compare(T_t *tp, uint8_t *cmp_buf, size_t cmp_buf_size) {
...
@@ -196,15 +196,15 @@ compare(T_t *tp, uint8_t *cmp_buf, size_t cmp_buf_size) {
*/
*/
erval
=
der_encode
(
&
asn_DEF_T
,
tp
,
buf_fill
,
0
);
erval
=
der_encode
(
&
asn_DEF_T
,
tp
,
buf_fill
,
0
);
assert
(
erval
.
encoded
!=
-
1
);
assert
(
erval
.
encoded
!=
-
1
);
if
(
erval
.
encoded
!=
cmp_buf_size
)
{
if
(
erval
.
encoded
!=
(
ssize_t
)
cmp_buf_size
)
{
printf
(
"%zd != %zd
\n
"
,
erval
.
encoded
,
cmp_buf_size
);
printf
(
"%zd != %zd
\n
"
,
erval
.
encoded
,
cmp_buf_size
);
}
}
assert
(
erval
.
encoded
==
cmp_buf_size
);
assert
(
erval
.
encoded
==
(
ssize_t
)
cmp_buf_size
);
for
(
i
=
0
;
i
<
cmp_buf_size
;
i
++
)
{
for
(
i
=
0
;
i
<
cmp_buf_size
;
i
++
)
{
if
(
buffer
[
i
]
!=
cmp_buf
[
i
])
{
if
(
buffer
[
i
]
!=
cmp_buf
[
i
])
{
fprintf
(
stderr
,
"Recreated buffer content mismatch:
\n
"
);
fprintf
(
stderr
,
"Recreated buffer content mismatch:
\n
"
);
fprintf
(
stderr
,
"Byte %d, %x != %x (%d != %d)
\n
"
,
fprintf
(
stderr
,
"Byte %d, %x != %x (%d != %d)
\n
"
,
i
,
(
int
)
i
,
buffer
[
i
],
cmp_buf
[
i
],
buffer
[
i
],
cmp_buf
[
i
],
buffer
[
i
],
cmp_buf
[
i
]
buffer
[
i
],
cmp_buf
[
i
]
);
);
...
@@ -214,70 +214,70 @@ compare(T_t *tp, uint8_t *cmp_buf, size_t cmp_buf_size) {
...
@@ -214,70 +214,70 @@ compare(T_t *tp, uint8_t *cmp_buf, size_t cmp_buf_size) {
}
}
static
void
static
void
partial_read
(
uint8_t
*
buf
,
size_t
size
)
{
partial_read
(
uint8_t
*
data
,
size_t
size
)
{
T_t
t
,
*
tp
;
T_t
t
,
*
tp
;
asn_dec_rval_t
rval
;
asn_dec_rval_t
rval
;
size_t
i1
,
i2
;
size_t
i1
,
i2
;
uint8_t
*
buf
1
=
alloca
(
size
);
uint8_t
*
data
1
=
alloca
(
size
);
uint8_t
*
buf
2
=
alloca
(
size
);
uint8_t
*
data
2
=
alloca
(
size
);
uint8_t
*
buf
3
=
alloca
(
size
);
uint8_t
*
data
3
=
alloca
(
size
);
fprintf
(
stderr
,
"
\n
Partial read sequence...
\n
"
);
fprintf
(
stderr
,
"
\n
Partial read sequence...
\n
"
);
/*
/*
* Divide the space (size) into three blocks in various combinations:
* Divide the space (size) into three blocks in various combinations:
* |<----->i1<----->i2<----->|
* |<----->i1<----->i2<----->|
* ^
buf ^ buf
+size
* ^
data ^ data
+size
* Try to read block by block.
* Try to read block by block.
*/
*/
for
(
i1
=
0
;
i1
<
size
;
i1
++
)
{
for
(
i1
=
0
;
i1
<
size
;
i1
++
)
{
for
(
i2
=
i1
;
i2
<
size
;
i2
++
)
{
for
(
i2
=
i1
;
i2
<
size
;
i2
++
)
{
uint8_t
*
chunk1
=
buf
;
uint8_t
*
chunk1
=
data
;
size_t
size1
=
i1
;
size_t
size1
=
i1
;
uint8_t
*
chunk2
=
buf
+
size1
;
uint8_t
*
chunk2
=
data
+
size1
;
size_t
size2
=
i2
-
i1
;
size_t
size2
=
i2
-
i1
;
uint8_t
*
chunk3
=
buf
+
size1
+
size2
;
uint8_t
*
chunk3
=
data
+
size1
+
size2
;
size_t
size3
=
size
-
size1
-
size2
;
size_t
size3
=
size
-
size1
-
size2
;
fprintf
(
stderr
,
"
\n
%zd:{%zd, %zd, %zd}...
\n
"
,
fprintf
(
stderr
,
"
\n
%zd:{%zd, %zd, %zd}...
\n
"
,
size
,
size1
,
size2
,
size3
);
size
,
size1
,
size2
,
size3
);
memset
(
buf
1
,
0
,
size
);
memset
(
data
1
,
0
,
size
);
memset
(
buf
2
,
0
,
size
);
memset
(
data
2
,
0
,
size
);
memset
(
buf
3
,
0
,
size
);
memset
(
data
3
,
0
,
size
);
memcpy
(
buf
1
,
chunk1
,
size1
);
memcpy
(
data
1
,
chunk1
,
size1
);
memcpy
(
buf
2
,
chunk2
,
size2
);
memcpy
(
data
2
,
chunk2
,
size2
);
memcpy
(
buf
3
,
chunk3
,
size3
);
memcpy
(
data
3
,
chunk3
,
size3
);
tp
=
memset
(
&
t
,
0
,
sizeof
(
t
));
tp
=
memset
(
&
t
,
0
,
sizeof
(
t
));
fprintf
(
stderr
,
"=> Chunk 1 (%zd):
\n
"
,
size1
);
fprintf
(
stderr
,
"=> Chunk 1 (%zd):
\n
"
,
size1
);
rval
=
ber_decode
(
0
,
&
asn_DEF_T
,
(
void
**
)
&
tp
,
rval
=
ber_decode
(
0
,
&
asn_DEF_T
,
(
void
**
)
&
tp
,
buf
1
,
size1
);
data
1
,
size1
);
assert
(
rval
.
code
==
RC_WMORE
);
assert
(
rval
.
code
==
RC_WMORE
);
assert
(
rval
.
consumed
<=
size1
);
assert
(
rval
.
consumed
<=
size1
);
if
(
rval
.
consumed
<
size1
)
{
if
(
rval
.
consumed
<
size1
)
{
int
leftover
=
size1
-
rval
.
consumed
;
int
leftover
=
size1
-
rval
.
consumed
;
memcpy
(
buf2
,
buf
1
+
rval
.
consumed
,
leftover
);
memcpy
(
data2
,
data
1
+
rval
.
consumed
,
leftover
);
memcpy
(
buf
2
+
leftover
,
chunk2
,
size2
);
memcpy
(
data
2
+
leftover
,
chunk2
,
size2
);
size2
+=
leftover
;
size2
+=
leftover
;
}
}
fprintf
(
stderr
,
"=> Chunk 2 (%zd):
\n
"
,
size2
);
fprintf
(
stderr
,
"=> Chunk 2 (%zd):
\n
"
,
size2
);
rval
=
ber_decode
(
0
,
&
asn_DEF_T
,
(
void
**
)
&
tp
,
rval
=
ber_decode
(
0
,
&
asn_DEF_T
,
(
void
**
)
&
tp
,
buf
2
,
size2
);
data
2
,
size2
);
assert
(
rval
.
code
==
RC_WMORE
);
assert
(
rval
.
code
==
RC_WMORE
);
assert
(
rval
.
consumed
<=
size2
);
assert
(
rval
.
consumed
<=
size2
);
if
(
rval
.
consumed
<
size2
)
{
if
(
rval
.
consumed
<
size2
)
{
int
leftover
=
size2
-
rval
.
consumed
;
int
leftover
=
size2
-
rval
.
consumed
;
memcpy
(
buf3
,
buf
2
+
rval
.
consumed
,
leftover
);
memcpy
(
data3
,
data
2
+
rval
.
consumed
,
leftover
);
memcpy
(
buf
3
+
leftover
,
chunk3
,
size3
);
memcpy
(
data
3
+
leftover
,
chunk3
,
size3
);
size3
+=
leftover
;
size3
+=
leftover
;
}
}
fprintf
(
stderr
,
"=> Chunk 3 (%zd):
\n
"
,
size3
);
fprintf
(
stderr
,
"=> Chunk 3 (%zd):
\n
"
,
size3
);
rval
=
ber_decode
(
0
,
&
asn_DEF_T
,
(
void
**
)
&
tp
,
rval
=
ber_decode
(
0
,
&
asn_DEF_T
,
(
void
**
)
&
tp
,
buf
3
,
size3
);
data
3
,
size3
);
assert
(
rval
.
code
==
RC_OK
);
assert
(
rval
.
code
==
RC_OK
);
assert
(
rval
.
consumed
==
size3
);
assert
(
rval
.
consumed
==
size3
);
...
...
asn1c/tests/check-41.c
View file @
5b63acf7
...
@@ -61,7 +61,7 @@ check(T_t *tp, uint8_t *buf, size_t size, size_t consumed) {
...
@@ -61,7 +61,7 @@ check(T_t *tp, uint8_t *buf, size_t size, size_t consumed) {
assert
(
rval
.
consumed
==
consumed
);
assert
(
rval
.
consumed
==
consumed
);
assert
(
tp
->
choice
.
seq
.
string
.
size
==
16
);
assert
(
tp
->
choice
.
seq
.
string
.
size
==
16
);
assert
(
strcmp
(
tp
->
choice
.
seq
.
string
.
buf
,
"zzzzzzzzzzzzzzzz"
)
==
0
);
assert
(
strcmp
(
(
char
*
)
tp
->
choice
.
seq
.
string
.
buf
,
"zzzzzzzzzzzzzzzz"
)
==
0
);
assert
(
tp
->
choice
.
seq
.
alpha
==
NULL
);
assert
(
tp
->
choice
.
seq
.
alpha
==
NULL
);
assert
(
tp
->
choice
.
seq
.
beta
);
assert
(
tp
->
choice
.
seq
.
beta
);
assert
(
*
tp
->
choice
.
seq
.
beta
==
0x4b4b4b4b
);
assert
(
*
tp
->
choice
.
seq
.
beta
==
0x4b4b4b4b
);
...
...
asn1c/tests/check-60.c
View file @
5b63acf7
...
@@ -102,7 +102,7 @@ main() {
...
@@ -102,7 +102,7 @@ main() {
assert
(
ret
==
0
);
assert
(
ret
==
0
);
assert
(
t1_new
.
i
==
112233
);
assert
(
t1_new
.
i
==
112233
);
assert
(
t1_new
.
any
.
size
==
sizeof
(
test_any_buf1
));
assert
(
t1_new
.
any
.
size
==
(
ssize_t
)
sizeof
(
test_any_buf1
));
assert
(
memcmp
(
t1_new
.
any
.
buf
,
test_any_buf1
,
sizeof
(
test_any_buf1
))
==
0
);
assert
(
memcmp
(
t1_new
.
any
.
buf
,
test_any_buf1
,
sizeof
(
test_any_buf1
))
==
0
);
/*
/*
...
@@ -121,7 +121,7 @@ main() {
...
@@ -121,7 +121,7 @@ main() {
assert
(
ret
==
0
);
assert
(
ret
==
0
);
assert
(
t1_new
.
i
==
-
112233
);
assert
(
t1_new
.
i
==
-
112233
);
assert
(
t1_new
.
any
.
size
==
sizeof
(
test_any_buf2
));
assert
(
t1_new
.
any
.
size
==
(
ssize_t
)
sizeof
(
test_any_buf2
));
assert
(
memcmp
(
t1_new
.
any
.
buf
,
test_any_buf2
,
sizeof
(
test_any_buf2
))
==
0
);
assert
(
memcmp
(
t1_new
.
any
.
buf
,
test_any_buf2
,
sizeof
(
test_any_buf2
))
==
0
);
/*
/*
...
@@ -160,7 +160,7 @@ main() {
...
@@ -160,7 +160,7 @@ main() {
assert
(
ret
==
0
);
assert
(
ret
==
0
);
assert
(
t2_new
.
i
==
332211
);
assert
(
t2_new
.
i
==
332211
);
assert
(
t2_new
.
any
->
size
==
sizeof
(
test_any_buf1
));
assert
(
t2_new
.
any
->
size
==
(
ssize_t
)
sizeof
(
test_any_buf1
));
assert
(
memcmp
(
t2_new
.
any
->
buf
,
test_any_buf1
,
sizeof
(
test_any_buf1
))
==
0
);
assert
(
memcmp
(
t2_new
.
any
->
buf
,
test_any_buf1
,
sizeof
(
test_any_buf1
))
==
0
);
/*
/*
...
@@ -180,7 +180,7 @@ main() {
...
@@ -180,7 +180,7 @@ main() {
assert
(
ret
==
0
);
assert
(
ret
==
0
);
assert
(
t2_new
.
i
==
0
);
assert
(
t2_new
.
i
==
0
);
assert
(
t2_new
.
any
->
size
==
sizeof
(
test_any_buf2
));
assert
(
t2_new
.
any
->
size
==
(
ssize_t
)
sizeof
(
test_any_buf2
));
assert
(
memcmp
(
t2_new
.
any
->
buf
,
test_any_buf2
,
sizeof
(
test_any_buf2
))
==
0
);
assert
(
memcmp
(
t2_new
.
any
->
buf
,
test_any_buf2
,
sizeof
(
test_any_buf2
))
==
0
);
/*
/*
...
...
asn1c/tests/check-62.c
View file @
5b63acf7
...
@@ -57,12 +57,12 @@ save_object(T_t *st) {
...
@@ -57,12 +57,12 @@ save_object(T_t *st) {
}
}
static
T_t
*
static
T_t
*
load_object
(
enum
expectation
expectation
,
char
*
fbuf
,
size_t
size
)
{
load_object
(
enum
expectation
expectation
,
unsigned
char
*
fbuf
,
size_t
size
)
{
asn_dec_rval_t
rval
;
asn_dec_rval_t
rval
;
T_t
*
st
=
0
;
T_t
*
st
=
0
;
int
csize
;
int
csize
;
fprintf
(
stderr
,
"LOADING OBJECT OF SIZE %d
\n
"
,
size
);
fprintf
(
stderr
,
"LOADING OBJECT OF SIZE %d
\n
"
,
(
int
)
size
);
/* Perform multiple iterations with multiple chunks sizes */
/* Perform multiple iterations with multiple chunks sizes */
for
(
csize
=
1
;
csize
<
20
;
csize
+=
1
)
{
for
(
csize
=
1
;
csize
<
20
;
csize
+=
1
)
{
...
@@ -90,7 +90,7 @@ load_object(enum expectation expectation, char *fbuf, size_t size) {
...
@@ -90,7 +90,7 @@ load_object(enum expectation expectation, char *fbuf, size_t size) {
if
(
expectation
!=
EXP_BROKEN
)
{
if
(
expectation
!=
EXP_BROKEN
)
{
assert
(
rval
.
code
==
RC_OK
);
assert
(
rval
.
code
==
RC_OK
);
assert
(
fbuf_offset
==
size
);
assert
(
fbuf_offset
==
(
ssize_t
)
size
);
}
else
{
}
else
{
assert
(
rval
.
code
!=
RC_OK
);
assert
(
rval
.
code
!=
RC_OK
);
fprintf
(
stderr
,
"Failed, but this was expected
\n
"
);
fprintf
(
stderr
,
"Failed, but this was expected
\n
"
);
...
@@ -105,7 +105,7 @@ load_object(enum expectation expectation, char *fbuf, size_t size) {
...
@@ -105,7 +105,7 @@ load_object(enum expectation expectation, char *fbuf, size_t size) {
static
void
static
void
process_data
(
enum
expectation
expectation
,
char
*
fbuf
,
ssize_t
size
)
{
process_data
(
enum
expectation
expectation
,
unsigned
char
*
fbuf
,
ssize_t
size
)
{
T_t
*
st
;
T_t
*
st
;
int
ret
;
int
ret
;
...
@@ -113,7 +113,7 @@ process_data(enum expectation expectation, char *fbuf, ssize_t size) {
...
@@ -113,7 +113,7 @@ process_data(enum expectation expectation, char *fbuf, ssize_t size) {
if
(
!
st
)
return
;
if
(
!
st
)
return
;
ret
=
save_object
(
st
);
ret
=
save_object
(
st
);
assert
(
buf_offset
<
sizeof
(
buf
));
assert
(
buf_offset
<
(
ssize_t
)
sizeof
(
buf
));
assert
(
ret
==
0
);
assert
(
ret
==
0
);
switch
(
expectation
)
{
switch
(
expectation
)
{
...
@@ -129,7 +129,7 @@ process_data(enum expectation expectation, char *fbuf, ssize_t size) {
...
@@ -129,7 +129,7 @@ process_data(enum expectation expectation, char *fbuf, ssize_t size) {
||
memcmp
(
buf
,
fbuf
,
buf_offset
));
||
memcmp
(
buf
,
fbuf
,
buf_offset
));
break
;
break
;
case
EXP_OK
:
case
EXP_OK
:
assert
(
buf_offset
==
size
);
assert
(
buf_offset
==
(
ssize_t
)
size
);
assert
(
memcmp
(
buf
,
fbuf
,
buf_offset
)
==
0
);
assert
(
memcmp
(
buf
,
fbuf
,
buf_offset
)
==
0
);
break
;
break
;
}
}
...
@@ -142,7 +142,7 @@ process_data(enum expectation expectation, char *fbuf, ssize_t size) {
...
@@ -142,7 +142,7 @@ process_data(enum expectation expectation, char *fbuf, ssize_t size) {
*/
*/
static
int
static
int
process
(
const
char
*
fname
)
{
process
(
const
char
*
fname
)
{
char
fbuf
[
4096
];
unsigned
char
fbuf
[
4096
];
char
*
ext
=
strrchr
(
fname
,
'.'
);
char
*
ext
=
strrchr
(
fname
,
'.'
);
enum
expectation
expectation
;
enum
expectation
expectation
;
int
ret
;
int
ret
;
...
@@ -175,7 +175,7 @@ process(const char *fname) {
...
@@ -175,7 +175,7 @@ process(const char *fname) {
rd
=
fread
(
fbuf
,
1
,
sizeof
(
fbuf
),
fp
);
rd
=
fread
(
fbuf
,
1
,
sizeof
(
fbuf
),
fp
);
fclose
(
fp
);
fclose
(
fp
);
assert
(
rd
<
sizeof
(
fbuf
));
/* expect small files */
assert
(
rd
<
(
ssize_t
)
sizeof
(
fbuf
));
/* expect small files */
process_data
(
expectation
,
fbuf
,
rd
);
process_data
(
expectation
,
fbuf
,
rd
);
...
...
asn1c/tests/check-70.-fwide-types.c
View file @
5b63acf7
...
@@ -10,6 +10,7 @@
...
@@ -10,6 +10,7 @@
#include <sys/types.h>
#include <sys/types.h>
#include <unistd.h>
/* for chdir(2) */
#include <unistd.h>
/* for chdir(2) */
#include <string.h>
#include <string.h>
#include <ctype.h>
#include <dirent.h>
#include <dirent.h>
#include <assert.h>
#include <assert.h>
#include <errno.h>
#include <errno.h>
...
@@ -88,7 +89,7 @@ save_object_as(PDU_t *st, enum der_or_xer how) {
...
@@ -88,7 +89,7 @@ save_object_as(PDU_t *st, enum der_or_xer how) {
}
}
static
PDU_t
*
static
PDU_t
*
load_object_from
(
enum
expectation
expectation
,
char
*
fbuf
,
size_t
size
,
enum
der_or_xer
how
)
{
load_object_from
(
enum
expectation
expectation
,
unsigned
char
*
fbuf
,
size_t
size
,
enum
der_or_xer
how
)
{
asn_dec_rval_t
rval
;
asn_dec_rval_t
rval
;
asn_dec_rval_t
(
*
zer_decode
)(
struct
asn_codec_ctx_s
*
,
asn_dec_rval_t
(
*
zer_decode
)(
struct
asn_codec_ctx_s
*
,
asn_TYPE_descriptor_t
*
,
void
**
,
const
void
*
,
size_t
);
asn_TYPE_descriptor_t
*
,
void
**
,
const
void
*
,
size_t
);
...
@@ -141,12 +142,12 @@ load_object_from(enum expectation expectation, char *fbuf, size_t size, enum der
...
@@ -141,12 +142,12 @@ load_object_from(enum expectation expectation, char *fbuf, size_t size, enum der
if
(
expectation
!=
EXP_BROKEN
)
{
if
(
expectation
!=
EXP_BROKEN
)
{
assert
(
rval
.
code
==
RC_OK
);
assert
(
rval
.
code
==
RC_OK
);
if
(
how
==
AS_DER
)
{
if
(
how
==
AS_DER
)
{
assert
(
fbuf_offset
==
size
);
assert
(
fbuf_offset
==
(
ssize_t
)
size
);
}
else
{
}
else
{
assert
(
fbuf_offset
-
size
<
2
assert
(
fbuf_offset
-
size
<
2
||
(
fbuf_offset
+
1
/* "\n" */
==
size
||
(
fbuf_offset
+
1
/* "\n" */
==
(
ssize_t
)
size
&&
fbuf
[
size
-
1
]
==
'\n'
)
&&
fbuf
[
size
-
1
]
==
'\n'
)
||
(
fbuf_offset
+
2
/* "\r\n" */
==
size
||
(
fbuf_offset
+
2
/* "\r\n" */
==
(
ssize_t
)
size
&&
fbuf
[
size
-
2
]
==
'\r'
&&
fbuf
[
size
-
2
]
==
'\r'
&&
fbuf
[
size
-
1
]
==
'\n'
)
&&
fbuf
[
size
-
1
]
==
'\n'
)
);
);
...
@@ -164,7 +165,9 @@ load_object_from(enum expectation expectation, char *fbuf, size_t size, enum der
...
@@ -164,7 +165,9 @@ load_object_from(enum expectation expectation, char *fbuf, size_t size, enum der
}
}
static
int
static
int
xer_encoding_equal
(
char
*
obuf
,
size_t
osize
,
char
*
nbuf
,
size_t
nsize
)
{
xer_encoding_equal
(
void
*
obufp
,
size_t
osize
,
void
*
nbufp
,
size_t
nsize
)
{
char
*
obuf
=
obufp
;
char
*
nbuf
=
nbufp
;
char
*
oend
=
obuf
+
osize
;
char
*
oend
=
obuf
+
osize
;
char
*
nend
=
nbuf
+
nsize
;
char
*
nend
=
nbuf
+
nsize
;
...
@@ -196,7 +199,7 @@ xer_encoding_equal(char *obuf, size_t osize, char *nbuf, size_t nsize) {
...
@@ -196,7 +199,7 @@ xer_encoding_equal(char *obuf, size_t osize, char *nbuf, size_t nsize) {
}
}
static
void
static
void
process_XER_data
(
enum
expectation
expectation
,
char
*
fbuf
,
size_t
size
)
{
process_XER_data
(
enum
expectation
expectation
,
unsigned
char
*
fbuf
,
size_t
size
)
{
PDU_t
*
st
;
PDU_t
*
st
;
st
=
load_object_from
(
expectation
,
fbuf
,
size
,
AS_XER
);
st
=
load_object_from
(
expectation
,
fbuf
,
size
,
AS_XER
);
...
@@ -226,12 +229,12 @@ process_XER_data(enum expectation expectation, char *fbuf, size_t size) {
...
@@ -226,12 +229,12 @@ process_XER_data(enum expectation expectation, char *fbuf, size_t size) {
break
;
break
;
case
EXP_CXER_EXACT
:
case
EXP_CXER_EXACT
:
buf
[
buf_offset
++
]
=
'\n'
;
buf
[
buf_offset
++
]
=
'\n'
;
assert
(
size
==
buf_offset
);
assert
(
(
ssize_t
)
size
==
buf_offset
);
assert
(
memcmp
(
fbuf
,
buf
,
size
)
==
0
);
assert
(
memcmp
(
fbuf
,
buf
,
size
)
==
0
);
break
;
break
;
case
EXP_CXER_DIFF
:
case
EXP_CXER_DIFF
:
buf
[
buf_offset
++
]
=
'\n'
;
buf
[
buf_offset
++
]
=
'\n'
;
assert
(
size
!=
buf_offset
assert
(
(
ssize_t
)
size
!=
buf_offset
||
memcmp
(
fbuf
,
buf
,
size
));
||
memcmp
(
fbuf
,
buf
,
size
));
break
;
break
;
case
EXP_OK
:
case
EXP_OK
:
...
@@ -247,7 +250,7 @@ process_XER_data(enum expectation expectation, char *fbuf, size_t size) {
...
@@ -247,7 +250,7 @@ process_XER_data(enum expectation expectation, char *fbuf, size_t size) {
*/
*/
static
int
static
int
process
(
const
char
*
fname
)
{
process
(
const
char
*
fname
)
{
char
fbuf
[
4096
];
unsigned
char
fbuf
[
4096
];
char
*
ext
=
strrchr
(
fname
,
'.'
);
char
*
ext
=
strrchr
(
fname
,
'.'
);
enum
expectation
expectation
;
enum
expectation
expectation
;
int
ret
;
int
ret
;
...
@@ -282,7 +285,7 @@ process(const char *fname) {
...
@@ -282,7 +285,7 @@ process(const char *fname) {
rd
=
fread
(
fbuf
,
1
,
sizeof
(
fbuf
),
fp
);
rd
=
fread
(
fbuf
,
1
,
sizeof
(
fbuf
),
fp
);
fclose
(
fp
);
fclose
(
fp
);
assert
(
rd
<
sizeof
(
fbuf
));
/* expect small files */
assert
(
rd
<
(
ssize_t
)
sizeof
(
fbuf
));
/* expect small files */
process_XER_data
(
expectation
,
fbuf
,
rd
);
process_XER_data
(
expectation
,
fbuf
,
rd
);
...
...
asn1c/tests/check-70.c
View file @
5b63acf7
...
@@ -78,7 +78,7 @@ save_object_as(PDU_t *st, enum der_or_xer how) {
...
@@ -78,7 +78,7 @@ save_object_as(PDU_t *st, enum der_or_xer how) {
}
}
static
PDU_t
*
static
PDU_t
*
load_object_from
(
enum
expectation
expectation
,
char
*
fbuf
,
size_t
size
,
enum
der_or_xer
how
)
{
load_object_from
(
enum
expectation
expectation
,
unsigned
char
*
fbuf
,
size_t
size
,
enum
der_or_xer
how
)
{
asn_dec_rval_t
rval
;
asn_dec_rval_t
rval
;
asn_dec_rval_t
(
*
zer_decode
)(
struct
asn_codec_ctx_s
*
,
asn_dec_rval_t
(
*
zer_decode
)(
struct
asn_codec_ctx_s
*
,
asn_TYPE_descriptor_t
*
,
void
**
,
const
void
*
,
size_t
);
asn_TYPE_descriptor_t
*
,
void
**
,
const
void
*
,
size_t
);
...
@@ -131,12 +131,12 @@ load_object_from(enum expectation expectation, char *fbuf, size_t size, enum der
...
@@ -131,12 +131,12 @@ load_object_from(enum expectation expectation, char *fbuf, size_t size, enum der
if
(
expectation
!=
EXP_BROKEN
)
{
if
(
expectation
!=
EXP_BROKEN
)
{
assert
(
rval
.
code
==
RC_OK
);
assert
(
rval
.
code
==
RC_OK
);
if
(
how
==
AS_DER
)
{
if
(
how
==
AS_DER
)
{
assert
(
fbuf_offset
==
size
);
assert
(
fbuf_offset
==
(
ssize_t
)
size
);
}
else
{
}
else
{
assert
(
fbuf_offset
-
size
<
2
assert
(
fbuf_offset
-
size
<
2
||
(
fbuf_offset
+
1
/* "\n" */
==
size
||
(
fbuf_offset
+
1
/* "\n" */
==
(
ssize_t
)
size
&&
fbuf
[
size
-
1
]
==
'\n'
)
&&
fbuf
[
size
-
1
]
==
'\n'
)
||
(
fbuf_offset
+
2
/* "\r\n" */
==
size
||
(
fbuf_offset
+
2
/* "\r\n" */
==
(
ssize_t
)
size
&&
fbuf
[
size
-
2
]
==
'\r'
&&
fbuf
[
size
-
2
]
==
'\r'
&&
fbuf
[
size
-
1
]
==
'\n'
)
&&
fbuf
[
size
-
1
]
==
'\n'
)
);
);
...
@@ -154,7 +154,9 @@ load_object_from(enum expectation expectation, char *fbuf, size_t size, enum der
...
@@ -154,7 +154,9 @@ load_object_from(enum expectation expectation, char *fbuf, size_t size, enum der
}
}
static
int
static
int
xer_encoding_equal
(
char
*
obuf
,
size_t
osize
,
char
*
nbuf
,
size_t
nsize
)
{
xer_encoding_equal
(
void
*
obufp
,
size_t
osize
,
void
*
nbufp
,
size_t
nsize
)
{
char
*
obuf
=
obufp
;
char
*
nbuf
=
nbufp
;
char
*
oend
=
obuf
+
osize
;
char
*
oend
=
obuf
+
osize
;
char
*
nend
=
nbuf
+
nsize
;
char
*
nend
=
nbuf
+
nsize
;
...
@@ -186,7 +188,7 @@ xer_encoding_equal(char *obuf, size_t osize, char *nbuf, size_t nsize) {
...
@@ -186,7 +188,7 @@ xer_encoding_equal(char *obuf, size_t osize, char *nbuf, size_t nsize) {
}
}
static
void
static
void
process_XER_data
(
enum
expectation
expectation
,
char
*
fbuf
,
size_t
size
)
{
process_XER_data
(
enum
expectation
expectation
,
unsigned
char
*
fbuf
,
size_t
size
)
{
PDU_t
*
st
;
PDU_t
*
st
;
st
=
load_object_from
(
expectation
,
fbuf
,
size
,
AS_XER
);
st
=
load_object_from
(
expectation
,
fbuf
,
size
,
AS_XER
);
...
@@ -224,7 +226,7 @@ process_XER_data(enum expectation expectation, char *fbuf, size_t size) {
...
@@ -224,7 +226,7 @@ process_XER_data(enum expectation expectation, char *fbuf, size_t size) {
*/
*/
static
int
static
int
process
(
const
char
*
fname
)
{
process
(
const
char
*
fname
)
{
char
fbuf
[
4096
];
unsigned
char
fbuf
[
4096
];
char
*
ext
=
strrchr
(
fname
,
'.'
);
char
*
ext
=
strrchr
(
fname
,
'.'
);
enum
expectation
expectation
;
enum
expectation
expectation
;
int
ret
;
int
ret
;
...
@@ -257,7 +259,7 @@ process(const char *fname) {
...
@@ -257,7 +259,7 @@ process(const char *fname) {
rd
=
fread
(
fbuf
,
1
,
sizeof
(
fbuf
),
fp
);
rd
=
fread
(
fbuf
,
1
,
sizeof
(
fbuf
),
fp
);
fclose
(
fp
);
fclose
(
fp
);
assert
(
rd
<
sizeof
(
fbuf
));
/* expect small files */
assert
(
rd
>
0
&&
(
size_t
)
rd
<
sizeof
(
fbuf
));
/* expect small files */
process_XER_data
(
expectation
,
fbuf
,
rd
);
process_XER_data
(
expectation
,
fbuf
,
rd
);
...
...
libasn1compiler/asn1c_constraint.c
View file @
5b63acf7
...
@@ -704,8 +704,8 @@ native_long_sign(asn1cnst_range_t *r) {
...
@@ -704,8 +704,8 @@ native_long_sign(asn1cnst_range_t *r) {
if
(
r
->
left
.
type
==
ARE_VALUE
if
(
r
->
left
.
type
==
ARE_VALUE
&&
r
->
left
.
value
>=
0
&&
r
->
left
.
value
>=
0
&&
r
->
right
.
type
==
ARE_VALUE
&&
r
->
right
.
type
==
ARE_VALUE
&&
r
->
right
.
value
>
2147483647
UL
&&
r
->
right
.
value
>
2147483647
&&
r
->
right
.
value
<=
4294967295UL
)
{
&&
(
unsigned
long
)
r
->
right
.
value
<=
4294967295UL
)
{
if
(
r
->
el_count
==
0
if
(
r
->
el_count
==
0
&&
r
->
left
.
value
==
0
&&
r
->
left
.
value
==
0
&&
r
->
right
.
value
==
4294967295UL
)
&&
r
->
right
.
value
==
4294967295UL
)
...
...
libasn1compiler/asn1c_misc.c
View file @
5b63acf7
...
@@ -379,7 +379,7 @@ asn1c_type_fits_long(arg_t *arg, asn1p_expr_t *expr) {
...
@@ -379,7 +379,7 @@ asn1c_type_fits_long(arg_t *arg, asn1p_expr_t *expr) {
&&
left
.
value
>=
0
&&
left
.
value
>=
0
&&
right
.
type
==
ARE_VALUE
&&
right
.
type
==
ARE_VALUE
&&
right
.
value
>
2147483647
&&
right
.
value
>
2147483647
&&
right
.
value
<=
4294967295UL
)
&&
(
unsigned
long
)
right
.
value
<=
4294967295UL
)
return
FL_FITS_UNSIGN
;
return
FL_FITS_UNSIGN
;
...
...
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