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
d9bd775a
Commit
d9bd775a
authored
Jun 05, 2004
by
Lev Walkin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
enforsed compilation with -W -Werror
parent
70e70287
Changes
55
Show whitespace changes
Inline
Side-by-side
Showing
55 changed files
with
223 additions
and
98 deletions
+223
-98
asn1c/tests/check-22.c
asn1c/tests/check-22.c
+10
-4
asn1c/tests/check-24.c
asn1c/tests/check-24.c
+4
-1
asn1c/tests/check-25.c
asn1c/tests/check-25.c
+9
-6
asn1c/tests/check-30.c
asn1c/tests/check-30.c
+4
-1
asn1c/tests/check-31.c
asn1c/tests/check-31.c
+4
-1
asn1c/tests/check-32.c
asn1c/tests/check-32.c
+3
-0
asn1c/tests/check-33.c
asn1c/tests/check-33.c
+3
-0
asn1c/tests/check-35.c
asn1c/tests/check-35.c
+4
-1
asn1c/tests/check-41.c
asn1c/tests/check-41.c
+4
-1
asn1c/tests/check-43.c
asn1c/tests/check-43.c
+3
-0
libasn1compiler/asn1c_misc.c
libasn1compiler/asn1c_misc.c
+2
-0
libasn1compiler/asn1c_save.c
libasn1compiler/asn1c_save.c
+2
-0
libasn1compiler/asn1compiler.c
libasn1compiler/asn1compiler.c
+2
-2
libasn1fix/asn1fix_class.c
libasn1fix/asn1fix_class.c
+2
-0
libasn1fix/asn1fix_integer.c
libasn1fix/asn1fix_integer.c
+1
-1
libasn1fix/asn1fix_misc.c
libasn1fix/asn1fix_misc.c
+3
-3
libasn1parser/asn1p_expr_str.h
libasn1parser/asn1p_expr_str.h
+7
-7
libasn1parser/asn1p_ref.c
libasn1parser/asn1p_ref.c
+2
-1
libasn1print/asn1print.c
libasn1print/asn1print.c
+6
-0
skeletons/BIT_STRING.c
skeletons/BIT_STRING.c
+2
-0
skeletons/BMPString.c
skeletons/BMPString.c
+4
-0
skeletons/BOOLEAN.c
skeletons/BOOLEAN.c
+7
-3
skeletons/ENUMERATED.c
skeletons/ENUMERATED.c
+2
-1
skeletons/GeneralString.c
skeletons/GeneralString.c
+1
-0
skeletons/GeneralizedTime.c
skeletons/GeneralizedTime.c
+5
-1
skeletons/GraphicString.c
skeletons/GraphicString.c
+1
-0
skeletons/IA5String.c
skeletons/IA5String.c
+1
-0
skeletons/INTEGER.c
skeletons/INTEGER.c
+10
-6
skeletons/ISO646String.c
skeletons/ISO646String.c
+1
-0
skeletons/NULL.c
skeletons/NULL.c
+6
-1
skeletons/NativeEnumerated.c
skeletons/NativeEnumerated.c
+2
-1
skeletons/NativeInteger.c
skeletons/NativeInteger.c
+8
-4
skeletons/NumericString.c
skeletons/NumericString.c
+1
-0
skeletons/OBJECT_IDENTIFIER.c
skeletons/OBJECT_IDENTIFIER.c
+8
-4
skeletons/OCTET_STRING.c
skeletons/OCTET_STRING.c
+29
-23
skeletons/ObjectDescriptor.c
skeletons/ObjectDescriptor.c
+1
-0
skeletons/PrintableString.c
skeletons/PrintableString.c
+1
-0
skeletons/RELATIVE-OID.c
skeletons/RELATIVE-OID.c
+5
-1
skeletons/T61String.c
skeletons/T61String.c
+1
-0
skeletons/TeletexString.c
skeletons/TeletexString.c
+1
-0
skeletons/UTCTime.c
skeletons/UTCTime.c
+7
-2
skeletons/UTF8String.c
skeletons/UTF8String.c
+4
-0
skeletons/UniversalString.c
skeletons/UniversalString.c
+4
-0
skeletons/VideotexString.c
skeletons/VideotexString.c
+1
-0
skeletons/VisibleString.c
skeletons/VisibleString.c
+1
-0
skeletons/ber_decoder.c
skeletons/ber_decoder.c
+1
-1
skeletons/ber_tlv_length.c
skeletons/ber_tlv_length.c
+3
-3
skeletons/ber_tlv_tag.c
skeletons/ber_tlv_tag.c
+3
-3
skeletons/constr_CHOICE.c
skeletons/constr_CHOICE.c
+2
-2
skeletons/constr_SEQUENCE.c
skeletons/constr_SEQUENCE.c
+2
-2
skeletons/constr_SEQUENCE_OF.c
skeletons/constr_SEQUENCE_OF.c
+1
-1
skeletons/constr_SET.c
skeletons/constr_SET.c
+2
-2
skeletons/constr_SET_OF.c
skeletons/constr_SET_OF.c
+5
-5
skeletons/constraints.c
skeletons/constraints.c
+14
-2
skeletons/der_encoder.c
skeletons/der_encoder.c
+1
-1
No files found.
asn1c/tests/check-22.c
View file @
d9bd775a
...
...
@@ -32,6 +32,9 @@ int buf2_pos;
static
int
buf2_fill
(
const
void
*
buffer
,
size_t
size
,
void
*
app_key
)
{
(
void
)
app_key
;
if
(
buf2_pos
+
size
>
sizeof
(
buf2
))
return
-
1
;
...
...
@@ -42,7 +45,7 @@ buf2_fill(const void *buffer, size_t size, void *app_key) {
}
static
void
check
(
int
is_ok
,
uint8_t
*
buf
,
int
size
,
in
t
consumed
)
{
check
(
int
is_ok
,
uint8_t
*
buf
,
int
size
,
size_
t
consumed
)
{
T1_t
t
,
*
tp
;
ber_dec_rval_t
rval
;
der_enc_rval_t
erval
;
...
...
@@ -57,7 +60,7 @@ check(int is_ok, uint8_t *buf, int size, int consumed) {
if
(
is_ok
)
{
assert
(
rval
.
code
==
RC_OK
);
assert
(
rval
.
consumed
==
consumed
);
assert
(
rval
.
consumed
==
(
size_t
)
consumed
);
assert
(
t
.
a
.
size
==
2
);
assert
(
t
.
b
.
present
==
b_PR_n
);
assert
(
t
.
b
.
choice
.
n
.
size
==
1
);
...
...
@@ -73,7 +76,7 @@ check(int is_ok, uint8_t *buf, int size, int consumed) {
||
t
.
c
.
size
!=
1
);
}
assert
(
rval
.
consumed
<=
consumed
);
assert
(
rval
.
consumed
<=
(
size_t
)
consumed
);
return
;
}
...
...
@@ -89,7 +92,7 @@ check(int is_ok, uint8_t *buf, int size, int consumed) {
printf
(
"%d != %d
\n
"
,
(
int
)
erval
.
encoded
,
(
int
)
sizeof
(
buf1
));
}
assert
(
erval
.
encoded
==
sizeof
(
buf1
));
for
(
i
=
0
;
i
<
sizeof
(
buf1
);
i
++
)
{
for
(
i
=
0
;
i
<
(
ssize_t
)
sizeof
(
buf1
);
i
++
)
{
if
(
buf1
[
i
]
!=
buf2
[
i
])
{
fprintf
(
stderr
,
"Recreated buffer content mismatch:
\n
"
);
fprintf
(
stderr
,
"Byte %d, %x != %x (%d != %d)
\n
"
,
...
...
@@ -133,6 +136,9 @@ try_corrupt(uint8_t *buf, int size) {
int
main
(
int
ac
,
char
**
av
)
{
(
void
)
ac
;
/* Unused argument */
(
void
)
av
;
/* Unused argument */
check
(
1
,
buf1
,
sizeof
(
buf1
),
sizeof
(
buf1
));
try_corrupt
(
buf1
,
sizeof
(
buf1
));
check
(
1
,
buf1
,
sizeof
(
buf1
)
+
10
,
sizeof
(
buf1
));
...
...
asn1c/tests/check-24.c
View file @
d9bd775a
...
...
@@ -34,7 +34,7 @@ uint8_t buf1[] = {
};
static
void
check
(
int
is_ok
,
uint8_t
*
buf
,
int
size
,
in
t
consumed
)
{
check
(
int
is_ok
,
uint8_t
*
buf
,
int
size
,
size_
t
consumed
)
{
T_t
t
,
*
tp
;
ber_dec_rval_t
rval
;
...
...
@@ -87,6 +87,9 @@ try_corrupt(uint8_t *buf, int size) {
int
main
(
int
ac
,
char
**
av
)
{
(
void
)
ac
;
/* Unused argument */
(
void
)
av
;
/* Unused argument */
check
(
1
,
buf1
,
sizeof
(
buf1
),
sizeof
(
buf1
));
try_corrupt
(
buf1
,
sizeof
(
buf1
));
...
...
asn1c/tests/check-25.c
View file @
d9bd775a
...
...
@@ -82,7 +82,7 @@ uint8_t buf1[] = {
};
static
void
check
(
int
is_ok
,
uint8_t
*
buf
,
int
size
,
in
t
consumed
)
{
check
(
int
is_ok
,
uint8_t
*
buf
,
int
size
,
size_
t
consumed
)
{
T_t
t
,
*
tp
;
ber_dec_rval_t
rval
;
...
...
@@ -164,10 +164,10 @@ try_corrupt(uint8_t *buf, int size, int allow_consume) {
}
static
void
partial_read
(
uint8_t
*
buf
,
in
t
size
)
{
partial_read
(
uint8_t
*
buf
,
size_
t
size
)
{
T_t
t
,
*
tp
;
ber_dec_rval_t
rval
;
in
t
i1
,
i2
;
size_
t
i1
,
i2
;
uint8_t
*
buf1
=
alloca
(
size
);
uint8_t
*
buf2
=
alloca
(
size
);
uint8_t
*
buf3
=
alloca
(
size
);
...
...
@@ -183,11 +183,11 @@ partial_read(uint8_t *buf, int size) {
for
(
i1
=
0
;
i1
<
size
;
i1
++
)
{
for
(
i2
=
i1
;
i2
<
size
;
i2
++
)
{
uint8_t
*
chunk1
=
buf
;
in
t
size1
=
i1
;
size_
t
size1
=
i1
;
uint8_t
*
chunk2
=
buf
+
size1
;
in
t
size2
=
i2
-
i1
;
size_
t
size2
=
i2
-
i1
;
uint8_t
*
chunk3
=
buf
+
size1
+
size2
;
in
t
size3
=
size
-
size1
-
size2
;
size_
t
size3
=
size
-
size1
-
size2
;
fprintf
(
stderr
,
"
\n
%d:{%d, %d, %d}...
\n
"
,
size
,
size1
,
size2
,
size3
);
...
...
@@ -239,6 +239,9 @@ partial_read(uint8_t *buf, int size) {
int
main
(
int
ac
,
char
**
av
)
{
(
void
)
ac
;
/* Unused argument */
(
void
)
av
;
/* Unused argument */
/* Check that the full buffer may be decoded normally */
check
(
1
,
buf1
,
sizeof
(
buf1
),
sizeof
(
buf1
)
-
3
);
...
...
asn1c/tests/check-30.c
View file @
d9bd775a
...
...
@@ -43,7 +43,7 @@ uint8_t buf2[] = {
};
static
void
check
(
int
is_ok
,
uint8_t
*
buf
,
int
size
,
in
t
consumed
)
{
check
(
int
is_ok
,
uint8_t
*
buf
,
int
size
,
size_
t
consumed
)
{
T_t
t
,
*
tp
;
ber_dec_rval_t
rval
;
...
...
@@ -103,6 +103,9 @@ try_corrupt(uint8_t *buf, int size) {
int
main
(
int
ac
,
char
**
av
)
{
(
void
)
ac
;
/* Unused argument */
(
void
)
av
;
/* Unused argument */
fprintf
(
stderr
,
"Must succeed:
\n
"
);
check
(
1
,
buf1
,
sizeof
(
buf1
)
+
20
,
sizeof
(
buf1
));
...
...
asn1c/tests/check-31.c
View file @
d9bd775a
...
...
@@ -92,7 +92,7 @@ int bytes_compare(const void *bufferp, size_t size, void *key) {
}
static
void
check
(
int
is_ok
,
uint8_t
*
buf
,
int
size
,
in
t
consumed
)
{
check
(
int
is_ok
,
uint8_t
*
buf
,
int
size
,
size_
t
consumed
)
{
Forest_t
t
,
*
tp
;
ber_dec_rval_t
rval
;
...
...
@@ -167,6 +167,9 @@ try_corrupt(uint8_t *buf, int size) {
int
main
(
int
ac
,
char
**
av
)
{
(
void
)
ac
;
/* Unused argument */
(
void
)
av
;
/* Unused argument */
check
(
1
,
buf1
,
sizeof
(
buf1
),
sizeof
(
buf1
));
try_corrupt
(
buf1
,
sizeof
(
buf1
));
check
(
1
,
buf1
,
sizeof
(
buf1
)
+
20
,
sizeof
(
buf1
));
...
...
asn1c/tests/check-32.c
View file @
d9bd775a
...
...
@@ -11,6 +11,9 @@ int
main
(
int
ac
,
char
**
av
)
{
Programming_t
p
;
(
void
)
ac
;
/* Unused argument */
(
void
)
av
;
/* Unused argument */
memset
(
&
p
,
0
,
sizeof
(
p
));
/*
...
...
asn1c/tests/check-33.c
View file @
d9bd775a
...
...
@@ -11,6 +11,9 @@ int
main
(
int
ac
,
char
**
av
)
{
T_t
t
;
(
void
)
ac
;
/* Unused argument */
(
void
)
av
;
/* Unused argument */
memset
(
&
t
,
0
,
sizeof
(
t
));
/*
...
...
asn1c/tests/check-35.c
View file @
d9bd775a
...
...
@@ -115,7 +115,7 @@ uint8_t buf2_reconstr[] = {
};
static
void
check
(
T_t
*
tp
,
uint8_t
*
buf
,
int
size
,
in
t
consumed
)
{
check
(
T_t
*
tp
,
uint8_t
*
buf
,
int
size
,
size_
t
consumed
)
{
ber_dec_rval_t
rval
;
tp
=
memset
(
tp
,
0
,
sizeof
(
*
tp
));
...
...
@@ -260,6 +260,9 @@ int
main
(
int
ac
,
char
**
av
)
{
T_t
t
;
(
void
)
ac
;
/* Unused argument */
(
void
)
av
;
/* Unused argument */
check
(
&
t
,
buf1
,
sizeof
(
buf1
)
+
10
,
sizeof
(
buf1
));
compare
(
&
t
,
buf1_reconstr
,
sizeof
(
buf1_reconstr
));
asn_fprint
(
stderr
,
&
asn1_DEF_T
,
&
t
);
...
...
asn1c/tests/check-41.c
View file @
d9bd775a
...
...
@@ -130,7 +130,7 @@ uint8_t buf2_reconstr[] = {
static
void
check
(
T_t
*
tp
,
uint8_t
*
buf
,
int
size
,
in
t
consumed
)
{
check
(
T_t
*
tp
,
uint8_t
*
buf
,
int
size
,
size_
t
consumed
)
{
ber_dec_rval_t
rval
;
tp
=
memset
(
tp
,
0
,
sizeof
(
*
tp
));
...
...
@@ -278,6 +278,9 @@ int
main
(
int
ac
,
char
**
av
)
{
T_t
t
;
(
void
)
ac
;
/* Unused argument */
(
void
)
av
;
/* Unused argument */
/* Check exact buf0 */
check
(
&
t
,
buf0
,
sizeof
(
buf0
),
sizeof
(
buf0
));
compare
(
&
t
,
buf0_reconstr
,
sizeof
(
buf0_reconstr
));
...
...
asn1c/tests/check-43.c
View file @
d9bd775a
...
...
@@ -13,6 +13,9 @@ main(int ac, char **av) {
Test_structure_1_t
ts1
;
Sets_t
s1
;
(
void
)
ac
;
/* Unused argument */
(
void
)
av
;
/* Unused argument */
memset
(
&
ts1
,
0
,
sizeof
(
ts1
));
memset
(
&
s1
,
0
,
sizeof
(
s1
));
...
...
libasn1compiler/asn1c_misc.c
View file @
d9bd775a
...
...
@@ -94,6 +94,8 @@ asn1c_open_file(arg_t *arg, const char *name, const char *ext) {
FILE
*
fp
;
int
fd
;
(
void
)
arg
;
/* Unused argument */
/*
* Compute filenames.
*/
...
...
libasn1compiler/asn1c_save.c
View file @
d9bd775a
...
...
@@ -208,6 +208,8 @@ static int
asn1c_copy_over
(
arg_t
*
arg
,
char
*
path
)
{
char
*
fname
=
basename
(
path
);
(
void
)
arg
;
/* Unused argument */
if
(
symlink
(
path
,
fname
))
{
if
(
errno
==
EEXIST
)
{
struct
stat
sb1
,
sb2
;
...
...
libasn1compiler/asn1compiler.c
View file @
d9bd775a
...
...
@@ -65,9 +65,9 @@ asn1c_compile_expr(arg_t *arg) {
int
(
*
type_cb
)(
arg_t
*
);
int
ret
;
assert
(
expr
->
meta_type
>=
AMT_INVALID
);
assert
(
(
int
)
expr
->
meta_type
>=
AMT_INVALID
);
assert
(
expr
->
meta_type
<
AMT_EXPR_META_MAX
);
assert
(
expr
->
expr_type
>=
A1TC_INVALID
);
assert
(
(
int
)
expr
->
expr_type
>=
A1TC_INVALID
);
assert
(
expr
->
expr_type
<
ASN_EXPR_TYPE_MAX
);
type_cb
=
asn1_lang_map
[
expr
->
meta_type
][
expr
->
expr_type
].
type_cb
;
...
...
libasn1fix/asn1fix_class.c
View file @
d9bd775a
...
...
@@ -30,6 +30,8 @@ asn1f_class_access(arg_t *arg, asn1p_ref_t *ref, asn1p_module_t **mod_r) {
asn1p_expr_t
*
result
;
asn1p_ref_t
tmpref
;
(
void
)
mod_r
;
/* Unused argument */
assert
(
ref
->
comp_count
>
1
);
DEBUG
(
"%s(%s) for line %d"
,
__func__
,
...
...
libasn1fix/asn1fix_integer.c
View file @
d9bd775a
...
...
@@ -114,7 +114,7 @@ static int
_asn1f_make_sure_type_is
(
arg_t
*
arg
,
asn1p_expr_t
*
expr
,
asn1p_expr_type_e
type
)
{
asn1p_module_t
*
mod
=
NULL
;
asn1p_expr_t
*
next_expr
;
int
expr_type
;
asn1p_expr_type_e
expr_type
;
int
ret
;
expr_type
=
expr
->
expr_type
;
...
...
libasn1fix/asn1fix_misc.c
View file @
d9bd775a
...
...
@@ -75,13 +75,13 @@ asn1f_printable_value(asn1p_value_t *v) {
}
case
ATV_REAL
:
ret
=
snprintf
(
buf
,
sizeof
(
buf
),
"%f"
,
v
->
value
.
v_double
);
if
(
ret
>=
sizeof
(
buf
))
if
(
ret
>=
(
ssize_t
)
sizeof
(
buf
))
memcpy
(
buf
+
sizeof
(
buf
)
-
4
,
"..."
,
4
);
return
buf
;
case
ATV_INTEGER
:
ret
=
snprintf
(
buf
,
sizeof
(
buf
),
"%lld"
,
(
long
long
)
v
->
value
.
v_integer
);
if
(
ret
>=
sizeof
(
buf
))
if
(
ret
>=
(
ssize_t
)
sizeof
(
buf
))
memcpy
(
buf
+
sizeof
(
buf
)
-
4
,
"..."
,
4
);
return
buf
;
case
ATV_MIN
:
return
"MIN"
;
...
...
@@ -126,7 +126,7 @@ asn1f_printable_value(asn1p_value_t *v) {
*
ptr
++
=
((
uc
>>
(
7
-
(
i
%
8
)))
&
1
)
?
'1'
:
'0'
;
}
}
else
{
char
hextable
[
16
]
=
"0123456789ABCDEF"
;
static
const
char
*
hextable
=
"0123456789ABCDEF"
;
/*
* Dump byte by byte.
*/
...
...
libasn1parser/asn1p_expr_str.h
View file @
d9bd775a
...
...
@@ -47,8 +47,8 @@ static char *asn1p_expr_type2str[] __attribute__ ((unused)) = {
*/
#define ASN_EXPR_TYPE2STR(type) \
( \
((type) < 0 \
|| (type) >= sizeof(asn1p_expr_type2str) \
((
(ssize_t)
type) < 0 \
|| (
(size_t)
type) >= sizeof(asn1p_expr_type2str) \
/ sizeof(asn1p_expr_type2str[0])) \
? (char *)0 \
: asn1p_expr_type2str[(type)] \
...
...
libasn1parser/asn1p_ref.c
View file @
d9bd775a
...
...
@@ -80,7 +80,8 @@ asn1p_ref_name2lextype(char *name) {
int
asn1p_ref_add_component
(
asn1p_ref_t
*
ref
,
char
*
name
,
enum
asn1p_ref_lex_type_e
lex_type
)
{
if
(
!
ref
||
!
name
||
lex_type
<
RLT_UNKNOWN
||
lex_type
>=
RLT_MAX
)
{
if
(
!
ref
||
!
name
||
(
int
)
lex_type
<
RLT_UNKNOWN
||
lex_type
>=
RLT_MAX
)
{
errno
=
EINVAL
;
return
-
1
;
}
...
...
libasn1print/asn1print.c
View file @
d9bd775a
...
...
@@ -84,6 +84,8 @@ asn1print_oid(asn1p_oid_t *oid, enum asn1print_flags_e flags) {
int
ac
;
int
accum
=
0
;
(
void
)
flags
;
/* Unused argument */
printf
(
"{"
);
for
(
ac
=
0
;
ac
<
oid
->
arcs_count
;
ac
++
)
{
if
(
accum
+
strlen
(
oid
->
arcs
[
ac
].
name
?:
""
)
>
50
)
{
...
...
@@ -111,6 +113,8 @@ static int
asn1print_ref
(
asn1p_ref_t
*
ref
,
enum
asn1print_flags_e
flags
)
{
int
cc
;
(
void
)
flags
;
/* Unused argument */
for
(
cc
=
0
;
cc
<
ref
->
comp_count
;
cc
++
)
{
if
(
cc
)
printf
(
"."
);
printf
(
"%s"
,
ref
->
components
[
cc
].
name
);
...
...
@@ -123,6 +127,8 @@ static int
asn1print_tag
(
asn1p_expr_t
*
tc
,
enum
asn1print_flags_e
flags
)
{
struct
asn1p_type_tag_s
*
tag
=
&
tc
->
tag
;
(
void
)
flags
;
/* Unused argument */
if
(
tag
->
tag_class
==
TC_NOCLASS
)
return
0
;
...
...
skeletons/BIT_STRING.c
View file @
d9bd775a
...
...
@@ -66,6 +66,8 @@ BIT_STRING_print(asn1_TYPE_descriptor_t *td, const void *sptr, int ilevel,
uint8_t
*
end
;
char
*
p
=
scratch
;
(
void
)
td
;
/* Unused argument */
if
(
!
st
||
!
st
->
buf
)
return
cb
(
"<absent>"
,
8
,
app_key
);
ilevel
+=
4
;
...
...
skeletons/BMPString.c
View file @
d9bd775a
...
...
@@ -23,6 +23,7 @@ asn1_TYPE_descriptor_t asn1_DEF_BMPString = {
/
sizeof
(
asn1_DEF_BMPString_tags
[
0
]),
1
,
/* Single UNIVERSAL tag may be implicitly overriden */
-
1
,
/* Both ways are fine */
0
/* No specifics */
};
/*
...
...
@@ -37,6 +38,9 @@ BMPString_print(asn1_TYPE_descriptor_t *td, const void *sptr, int ilevel,
char
scratch
[
128
];
/* Scratchpad buffer */
char
*
p
;
(
void
)
td
;
/* Unused argument */
(
void
)
ilevel
;
/* Unused argument */
if
(
!
st
||
!
st
->
buf
)
return
cb
(
"<absent>"
,
8
,
app_key
);
wchar
=
(
uint16_t
*
)
st
->
buf
;
...
...
skeletons/BOOLEAN.c
View file @
d9bd775a
...
...
@@ -21,7 +21,8 @@ asn1_TYPE_descriptor_t asn1_DEF_BOOLEAN = {
asn1_DEF_BOOLEAN_tags
,
sizeof
(
asn1_DEF_BOOLEAN_tags
)
/
sizeof
(
asn1_DEF_BOOLEAN_tags
[
0
]),
1
,
/* Single UNIVERSAL tag may be implicitly overriden */
0
/* Always in primitive form */
0
,
/* Always in primitive form */
0
/* No specifics */
};
/*
...
...
@@ -33,7 +34,7 @@ BOOLEAN_decode_ber(asn1_TYPE_descriptor_t *td,
int
tag_mode
)
{
BOOLEAN_t
*
st
=
*
bool_structure
;
ber_dec_rval_t
rval
;
ber_dec_ctx_t
ctx
=
{
0
};
ber_dec_ctx_t
ctx
=
{
0
,
0
,
0
,
0
};
ber_tlv_len_t
length
;
ber_tlv_len_t
lidx
;
...
...
@@ -61,7 +62,7 @@ BOOLEAN_decode_ber(asn1_TYPE_descriptor_t *td,
buf_ptr
+=
rval
.
consumed
;
size
-=
rval
.
consumed
;
if
(
length
>
size
)
{
if
(
length
>
(
ber_tlv_len_t
)
size
)
{
rval
.
code
=
RC_WMORE
;
rval
.
consumed
=
0
;
return
rval
;
...
...
@@ -128,6 +129,9 @@ BOOLEAN_print(asn1_TYPE_descriptor_t *td, const void *sptr, int ilevel,
asn_app_consume_bytes_f
*
cb
,
void
*
app_key
)
{
const
BOOLEAN_t
*
st
=
sptr
;
(
void
)
td
;
/* Unused argument */
(
void
)
ilevel
;
/* Unused argument */
if
(
st
)
{
if
(
st
->
value
)
return
cb
(
"TRUE"
,
4
,
app_key
);
...
...
skeletons/ENUMERATED.c
View file @
d9bd775a
...
...
@@ -21,6 +21,7 @@ asn1_TYPE_descriptor_t asn1_DEF_ENUMERATED = {
asn1_DEF_ENUMERATED_tags
,
sizeof
(
asn1_DEF_ENUMERATED_tags
)
/
sizeof
(
asn1_DEF_ENUMERATED_tags
[
0
]),
1
,
/* Single UNIVERSAL tag may be implicitly overriden */
0
/* Primitive */
0
,
/* Primitive */
0
/* No specifics */
};
skeletons/GeneralString.c
View file @
d9bd775a
...
...
@@ -23,5 +23,6 @@ asn1_TYPE_descriptor_t asn1_DEF_GeneralString = {
/
sizeof
(
asn1_DEF_GeneralString_tags
[
0
]),
1
,
/* Single UNIVERSAL tag may be implicitly overriden */
-
1
,
/* Both ways are fine */
0
/* No specifics */
};
skeletons/GeneralizedTime.c
View file @
d9bd775a
...
...
@@ -30,6 +30,7 @@ asn1_TYPE_descriptor_t asn1_DEF_GeneralizedTime = {
/
sizeof
(
asn1_DEF_GeneralizedTime_tags
[
0
]),
1
,
/* Single UNIVERSAL tag may be implicitly overriden */
-
1
,
/* Both ways are fine */
0
/* No specifics */
};
#endif
/* __NO_ASN_TABLE__ */
...
...
@@ -59,6 +60,9 @@ GeneralizedTime_print(asn1_TYPE_descriptor_t *td, const void *sptr, int ilevel,
asn_app_consume_bytes_f
*
cb
,
void
*
app_key
)
{
const
GeneralizedTime_t
*
st
=
sptr
;
(
void
)
td
;
/* Unused argument */
(
void
)
ilevel
;
/* Unused argument */
if
(
st
&&
st
->
buf
)
{
char
buf
[
32
];
struct
tm
tm
;
...
...
@@ -72,7 +76,7 @@ GeneralizedTime_print(asn1_TYPE_descriptor_t *td, const void *sptr, int ilevel,
"%04d-%02d-%02d %02d:%02d%02d"
,
tm
.
tm_year
+
1900
,
tm
.
tm_mon
+
1
,
tm
.
tm_mday
,
tm
.
tm_hour
,
tm
.
tm_min
,
tm
.
tm_sec
);
assert
(
ret
>
0
&&
ret
<
sizeof
(
buf
));
assert
(
ret
>
0
&&
ret
<
(
int
)
sizeof
(
buf
));
return
cb
(
buf
,
ret
,
app_key
);
}
else
{
return
cb
(
"<absent>"
,
8
,
app_key
);
...
...
skeletons/GraphicString.c
View file @
d9bd775a
...
...
@@ -23,5 +23,6 @@ asn1_TYPE_descriptor_t asn1_DEF_GraphicString = {
/
sizeof
(
asn1_DEF_GraphicString_tags
[
0
]),
1
,
/* Single UNIVERSAL tag may be implicitly overriden */
-
1
,
/* Both ways are fine */
0
/* No specifics */
};
skeletons/IA5String.c
View file @
d9bd775a
...
...
@@ -23,6 +23,7 @@ asn1_TYPE_descriptor_t asn1_DEF_IA5String = {
/
sizeof
(
asn1_DEF_IA5String_tags
[
0
]),
1
,
/* Single UNIVERSAL tag may be implicitly overriden */
-
1
,
/* Both ways are fine */
0
/* No specifics */
};
int
...
...
skeletons/INTEGER.c
View file @
d9bd775a
...
...
@@ -23,7 +23,8 @@ asn1_TYPE_descriptor_t asn1_DEF_INTEGER = {
asn1_DEF_INTEGER_tags
,
sizeof
(
asn1_DEF_INTEGER_tags
)
/
sizeof
(
asn1_DEF_INTEGER_tags
[
0
]),
1
,
/* Single UNIVERSAL tag may be implicitly overriden */
0
/* Always in primitive form */
0
,
/* Always in primitive form */
0
/* No specifics */
};
/*
...
...
@@ -34,7 +35,7 @@ INTEGER_decode_ber(asn1_TYPE_descriptor_t *td,
void
**
int_structure
,
void
*
buf_ptr
,
size_t
size
,
int
tag_mode
)
{
INTEGER_t
*
st
=
*
int_structure
;
ber_dec_rval_t
rval
;
ber_dec_ctx_t
ctx
=
{
0
};
ber_dec_ctx_t
ctx
=
{
0
,
0
,
0
,
0
};
ber_tlv_len_t
length
;
/*
...
...
@@ -67,7 +68,7 @@ INTEGER_decode_ber(asn1_TYPE_descriptor_t *td,
*/
buf_ptr
+=
rval
.
consumed
;
size
-=
rval
.
consumed
;
if
(
length
>
size
)
{
if
(
length
>
(
ber_tlv_len_t
)
size
)
{
rval
.
code
=
RC_WMORE
;
rval
.
consumed
=
0
;
return
rval
;
...
...
@@ -193,25 +194,28 @@ INTEGER_print(asn1_TYPE_descriptor_t *td, const void *sptr, int ilevel,
char
*
p
;
int
ret
;
(
void
)
td
;
/* Unused argument */
(
void
)
ilevel
;
/* Unused argument */
if
(
!
st
&&
!
st
->
buf
)
return
cb
(
"<absent>"
,
8
,
app_key
);
if
(
st
->
size
==
0
)
return
cb
(
"0"
,
1
,
app_key
);
/* Simple case: the integer size is small */
if
(
st
->
size
<
sizeof
(
accum
)
||
(
st
->
buf
[
0
]
&
0x80
))
{
if
(
(
size_t
)
st
->
size
<
sizeof
(
accum
)
||
(
st
->
buf
[
0
]
&
0x80
))
{
accum
=
(
st
->
buf
[
0
]
&
0x80
)
?
-
1
:
0
;
for
(;
buf
<
buf_end
;
buf
++
)
accum
=
(
accum
<<
8
)
|
*
buf
;
ret
=
snprintf
(
scratch
,
sizeof
(
scratch
),
"%ld"
,
accum
);
assert
(
ret
>
0
&&
ret
<
sizeof
(
scratch
));
assert
(
ret
>
0
&&
ret
<
(
int
)
sizeof
(
scratch
));
return
cb
(
scratch
,
ret
,
app_key
);
}
/* Output in the long xx:yy:zz... format */
for
(
p
=
scratch
;
buf
<
buf_end
;
buf
++
)
{
static
char
h2c
[
16
]
=
"0123456789ABCDEF"
;
if
((
p
-
scratch
)
>=
(
sizeof
(
scratch
)
/
2
))
{
if
((
p
-
scratch
)
>=
(
s
size_t
)(
s
izeof
(
scratch
)
/
2
))
{
/* Flush buffer */
if
(
cb
(
scratch
,
p
-
scratch
,
app_key
))
return
-
1
;
...
...
skeletons/ISO646String.c
View file @
d9bd775a
...
...
@@ -23,5 +23,6 @@ asn1_TYPE_descriptor_t asn1_DEF_ISO646String = {
/
sizeof
(
asn1_DEF_ISO646String_tags
[
0
]),
1
,
/* Single UNIVERSAL tag may be implicitly overriden */
-
1
,
/* Both ways are fine */
0
/* No specifics */
};
skeletons/NULL.c
View file @
d9bd775a
...
...
@@ -22,7 +22,8 @@ asn1_TYPE_descriptor_t asn1_DEF_NULL = {
asn1_DEF_NULL_tags
,
sizeof
(
asn1_DEF_NULL_tags
)
/
sizeof
(
asn1_DEF_NULL_tags
[
0
]),
1
,
/* Single UNIVERSAL tag may be implicitly overriden */
0
/* Always in primitive form */
0
,
/* Always in primitive form */
0
/* No specifics */
};
der_enc_rval_t
...
...
@@ -43,6 +44,10 @@ NULL_encode_der(asn1_TYPE_descriptor_t *sd, void *ptr,
int
NULL_print
(
asn1_TYPE_descriptor_t
*
td
,
const
void
*
sptr
,
int
ilevel
,
asn_app_consume_bytes_f
*
cb
,
void
*
app_key
)
{
(
void
)
td
;
/* Unused argument */
(
void
)
ilevel
;
/* Unused argument */
if
(
sptr
)
{
return
cb
(
"<present>"
,
9
,
app_key
);
}
else
{
...
...
skeletons/NativeEnumerated.c
View file @
d9bd775a
...
...
@@ -28,5 +28,6 @@ asn1_TYPE_descriptor_t asn1_DEF_NativeEnumerated = {
asn1_DEF_NativeEnumerated_tags
,
sizeof
(
asn1_DEF_NativeEnumerated_tags
)
/
sizeof
(
asn1_DEF_NativeEnumerated_tags
[
0
]),
1
,
/* Single UNIVERSAL tag may be implicitly overriden */
0
/* Always in primitive form */
0
,
/* Always in primitive form */
0
/* No specifics */
};
skeletons/NativeInteger.c
View file @
d9bd775a
...
...
@@ -30,7 +30,8 @@ asn1_TYPE_descriptor_t asn1_DEF_NativeInteger = {
asn1_DEF_NativeInteger_tags
,
sizeof
(
asn1_DEF_NativeInteger_tags
)
/
sizeof
(
asn1_DEF_NativeInteger_tags
[
0
]),
1
,
/* Single UNIVERSAL tag may be implicitly overriden */
0
/* Always in primitive form */
0
,
/* Always in primitive form */
0
/* No specifics */
};
/*
...
...
@@ -41,7 +42,7 @@ NativeInteger_decode_ber(asn1_TYPE_descriptor_t *td,
void
**
int_ptr
,
void
*
buf_ptr
,
size_t
size
,
int
tag_mode
)
{
int
*
Int
=
*
int_ptr
;
ber_dec_rval_t
rval
;
ber_dec_ctx_t
ctx
=
{
0
};
ber_dec_ctx_t
ctx
=
{
0
,
0
,
0
,
0
};
ber_tlv_len_t
length
;
/*
...
...
@@ -74,7 +75,7 @@ NativeInteger_decode_ber(asn1_TYPE_descriptor_t *td,
*/
buf_ptr
+=
rval
.
consumed
;
size
-=
rval
.
consumed
;
if
(
length
>
size
)
{
if
(
length
>
(
ber_tlv_len_t
)
size
)
{
rval
.
code
=
RC_WMORE
;
rval
.
consumed
=
0
;
return
rval
;
...
...
@@ -168,9 +169,12 @@ NativeInteger_print(asn1_TYPE_descriptor_t *td, const void *sptr, int ilevel,
char
scratch
[
32
];
int
ret
;
(
void
)
td
;
/* Unused argument */
(
void
)
ilevel
;
/* Unused argument */
if
(
Int
)
{
ret
=
snprintf
(
scratch
,
sizeof
(
scratch
),
"%d"
,
*
Int
);
assert
(
ret
>
0
&&
ret
<
sizeof
(
scratch
));
assert
(
ret
>
0
&&
ret
<
(
int
)
sizeof
(
scratch
));
return
cb
(
scratch
,
ret
,
app_key
);
}
else
{
return
cb
(
"<absent>"
,
8
,
app_key
);
...
...
skeletons/NumericString.c
View file @
d9bd775a
...
...
@@ -23,6 +23,7 @@ asn1_TYPE_descriptor_t asn1_DEF_NumericString = {
/
sizeof
(
asn1_DEF_NumericString_tags
[
0
]),
1
,
/* Single UNIVERSAL tag may be implicitly overriden */
-
1
,
/* Both ways are fine */
0
/* No specifics */
};
int
...
...
skeletons/OBJECT_IDENTIFIER.c
View file @
d9bd775a
...
...
@@ -24,7 +24,8 @@ asn1_TYPE_descriptor_t asn1_DEF_OBJECT_IDENTIFIER = {
sizeof
(
asn1_DEF_OBJECT_IDENTIFIER_tags
)
/
sizeof
(
asn1_DEF_OBJECT_IDENTIFIER_tags
[
0
]),
1
,
/* Single UNIVERSAL tag may be implicitly overriden */
0
/* Always in primitive form */
0
,
/* Always in primitive form */
0
/* No specifics */
};
...
...
@@ -94,8 +95,8 @@ OBJECT_IDENTIFIER_get_arc_l(uint8_t *arcbuf, int arclen, int add, unsigned long
unsigned
long
accum
;
uint8_t
*
arcend
=
arcbuf
+
arclen
;
if
(
arclen
*
7
>
8
*
sizeof
(
accum
))
{
if
(
arclen
*
7
<=
8
*
(
sizeof
(
accum
)
+
1
))
{
if
(
(
size_t
)
arclen
*
7
>
8
*
sizeof
(
accum
))
{
if
(
(
size_t
)
arclen
*
7
<=
8
*
(
sizeof
(
accum
)
+
1
))
{
if
((
*
arcbuf
&
~
0x8f
))
{
errno
=
ERANGE
;
/* Overflow */
return
-
1
;
...
...
@@ -110,8 +111,8 @@ OBJECT_IDENTIFIER_get_arc_l(uint8_t *arcbuf, int arclen, int add, unsigned long
for
(
accum
=
0
;
arcbuf
<
arcend
;
arcbuf
++
)
accum
=
(
accum
<<
7
)
|
(
*
arcbuf
&
~
0x80
);
assert
(
accum
>=
(
unsigned
long
)
-
add
);
accum
+=
add
;
/* Actually, a negative value */
assert
(
accum
>=
0
);
*
rvalue
=
accum
;
...
...
@@ -144,6 +145,9 @@ OBJECT_IDENTIFIER_print(asn1_TYPE_descriptor_t *td, const void *sptr,
int
add
=
0
;
int
i
;
(
void
)
td
;
/* Unused argument */
(
void
)
ilevel
;
/* Unused argument */
if
(
!
st
||
!
st
->
buf
)
return
cb
(
"<absent>"
,
8
,
app_key
);
...
...
skeletons/OCTET_STRING.c
View file @
d9bd775a
...
...
@@ -25,6 +25,7 @@ asn1_TYPE_descriptor_t asn1_DEF_OCTET_STRING = {
/
sizeof
(
asn1_DEF_OCTET_STRING_tags
[
0
]),
1
,
/* Single UNIVERSAL tag may be implicitly overriden */
-
1
,
/* Both ways are fine (primitive and constructed) */
0
/* No specifics */
};
#define _CH_PHASE(ctx, inc) do { \
...
...
@@ -49,11 +50,11 @@ asn1_TYPE_descriptor_t asn1_DEF_OCTET_STRING = {
} while(0)
#define APPEND(bufptr, bufsize) do { \
int _ns = ctx->step;
/* Allocated */
\
if(_ns <= (s
t->size + bufsize)) {
\
size_t _ns = ctx->step;
/* Allocated */
\
if(_ns <= (s
ize_t)(st->size + bufsize)) {
\
void *ptr; \
do { _ns = _ns ? _ns<<2 : 16; } \
while(_ns <= (st->size + bufsize)); \
while(_ns <= (s
ize_t)(s
t->size + bufsize)); \
ptr = REALLOC(st->buf, _ns); \
if(ptr) { \
st->buf = ptr; \
...
...
@@ -315,7 +316,7 @@ OCTET_STRING_decode_ber(asn1_TYPE_descriptor_t *td,
assert
(
sel
->
left
>=
0
);
len
=
(
size
<
sel
->
left
)
?
size
:
sel
->
left
;
len
=
(
(
ber_tlv_len_t
)
size
<
sel
->
left
)
?
size
:
sel
->
left
;
if
(
len
>
0
)
{
if
(
is_bit_str
&&
sel
->
bits_chopped
==
0
)
{
/*
...
...
@@ -350,7 +351,7 @@ OCTET_STRING_decode_ber(asn1_TYPE_descriptor_t *td,
/*
* Primitive form, no stack required.
*/
if
(
size
<
ctx
->
left
)
{
if
(
size
<
(
size_t
)
ctx
->
left
)
{
APPEND
(
buf_ptr
,
size
);
ctx
->
left
-=
size
;
ADVANCE
(
size
);
...
...
@@ -465,6 +466,8 @@ OCTET_STRING_print(asn1_TYPE_descriptor_t *td, const void *sptr, int ilevel,
size_t
i
;
int
ret
;
(
void
)
td
;
/* Unused argument */
if
(
!
st
||
!
st
->
buf
)
return
cb
(
"<absent>"
,
8
,
app_key
);
/*
...
...
@@ -494,6 +497,9 @@ OCTET_STRING_print_ascii(asn1_TYPE_descriptor_t *td, const void *sptr,
int
ilevel
,
asn_app_consume_bytes_f
*
cb
,
void
*
app_key
)
{
const
OCTET_STRING_t
*
st
=
sptr
;
(
void
)
td
;
/* Unused argument */
(
void
)
ilevel
;
/* Unused argument */
if
(
st
&&
st
->
buf
)
{
return
cb
(
st
->
buf
,
st
->
size
,
app_key
);
}
else
{
...
...
skeletons/ObjectDescriptor.c
View file @
d9bd775a
...
...
@@ -23,5 +23,6 @@ asn1_TYPE_descriptor_t asn1_DEF_ObjectDescriptor = {
/
sizeof
(
asn1_DEF_ObjectDescriptor_tags
[
0
]),
1
,
/* Single UNIVERSAL tag may be implicitly overriden */
-
1
,
/* Both ways are fine */
0
/* No specifics */
};
skeletons/PrintableString.c
View file @
d9bd775a
...
...
@@ -23,6 +23,7 @@ asn1_TYPE_descriptor_t asn1_DEF_PrintableString = {
/
sizeof
(
asn1_DEF_PrintableString_tags
[
0
]),
1
,
/* Single UNIVERSAL tag may be implicitly overriden */
-
1
,
/* Both ways are fine */
0
/* No specifics */
};
...
...
skeletons/RELATIVE-OID.c
View file @
d9bd775a
...
...
@@ -24,7 +24,8 @@ asn1_TYPE_descriptor_t asn1_DEF_RELATIVE_OID = {
sizeof
(
asn1_DEF_RELATIVE_OID_tags
)
/
sizeof
(
asn1_DEF_RELATIVE_OID_tags
[
0
]),
1
,
/* Single UNIVERSAL tag may be implicitly overriden */
0
/* Always in primitive form */
0
,
/* Always in primitive form */
0
/* No specifics */
};
int
...
...
@@ -34,6 +35,9 @@ RELATIVE_OID_print(asn1_TYPE_descriptor_t *td, const void *sptr, int ilevel,
int
startn
;
int
i
;
(
void
)
td
;
/* Unused argument */
(
void
)
ilevel
;
/* Unused argument */
if
(
!
st
||
!
st
->
buf
)
return
cb
(
"<absent>"
,
8
,
app_key
);
...
...
skeletons/T61String.c
View file @
d9bd775a
...
...
@@ -23,5 +23,6 @@ asn1_TYPE_descriptor_t asn1_DEF_T61String = {
/
sizeof
(
asn1_DEF_T61String_tags
[
0
]),
1
,
/* Single UNIVERSAL tag may be implicitly overriden */
-
1
,
/* Both ways are fine */
0
/* No specifics */
};
skeletons/TeletexString.c
View file @
d9bd775a
...
...
@@ -23,5 +23,6 @@ asn1_TYPE_descriptor_t asn1_DEF_TeletexString = {
/
sizeof
(
asn1_DEF_TeletexString_tags
[
0
]),
1
,
/* Single UNIVERSAL tag may be implicitly overriden */
-
1
,
/* Both ways are fine */
0
/* No specifics */
};
skeletons/UTCTime.c
View file @
d9bd775a
...
...
@@ -29,6 +29,7 @@ asn1_TYPE_descriptor_t asn1_DEF_UTCTime = {
/
sizeof
(
asn1_DEF_UTCTime_tags
[
0
]),
1
,
/* Single UNIVERSAL tag may be implicitly overriden */
-
1
,
/* Both ways are fine */
0
/* No specifics */
};
#endif
/* __NO_ASN_TABLE__ */
...
...
@@ -58,6 +59,9 @@ UTCTime_print(asn1_TYPE_descriptor_t *td, const void *sptr, int ilevel,
asn_app_consume_bytes_f
*
cb
,
void
*
app_key
)
{
const
UTCTime_t
*
st
=
sptr
;
(
void
)
td
;
/* Unused argument */
(
void
)
ilevel
;
/* Unused argument */
if
(
st
&&
st
->
buf
)
{
char
buf
[
32
];
struct
tm
tm
;
...
...
@@ -71,7 +75,7 @@ UTCTime_print(asn1_TYPE_descriptor_t *td, const void *sptr, int ilevel,
"%04d-%02d-%02d %02d:%02d%02d"
,
tm
.
tm_year
+
1900
,
tm
.
tm_mon
+
1
,
tm
.
tm_mday
,
tm
.
tm_hour
,
tm
.
tm_min
,
tm
.
tm_sec
);
assert
(
ret
>
0
&&
ret
<
sizeof
(
buf
));
assert
(
ret
>
0
&&
ret
<
(
int
)
sizeof
(
buf
));
return
cb
(
buf
,
ret
,
app_key
);
}
else
{
return
cb
(
"<absent>"
,
8
,
app_key
);
...
...
@@ -83,7 +87,8 @@ asn_UT2time(const UTCTime_t *st, struct tm *_tm) {
char
buf
[
17
+
2
];
/* "AAMMJJhhmmss+hhmm" = 17, + 2 = 19 */
GeneralizedTime_t
gt
;
if
(
!
st
||
!
st
->
buf
||
st
->
size
<
11
||
st
->
size
>
(
sizeof
(
buf
)
-
2
))
{
if
(
!
st
||
!
st
->
buf
||
st
->
size
<
11
||
st
->
size
>
((
int
)
sizeof
(
buf
)
-
2
))
{
errno
=
EINVAL
;
return
-
1
;
}
...
...
skeletons/UTF8String.c
View file @
d9bd775a
...
...
@@ -23,6 +23,7 @@ asn1_TYPE_descriptor_t asn1_DEF_UTF8String = {
/
sizeof
(
asn1_DEF_UTF8String_tags
[
0
]),
1
,
/* Single UNIVERSAL tag may be implicitly overriden */
-
1
,
/* Both ways are fine */
0
/* No specifics */
};
static
int
_UTF8String_h1
[
16
]
=
{
...
...
@@ -104,6 +105,9 @@ UTF8String_print(asn1_TYPE_descriptor_t *td, const void *sptr, int ilevel,
asn_app_consume_bytes_f
*
cb
,
void
*
app_key
)
{
const
UTF8String_t
*
st
=
sptr
;
(
void
)
td
;
/* Unused argument */
(
void
)
ilevel
;
/* Unused argument */
if
(
st
&&
st
->
buf
)
{
return
cb
(
st
->
buf
,
st
->
size
,
app_key
);
}
else
{
...
...
skeletons/UniversalString.c
View file @
d9bd775a
...
...
@@ -23,6 +23,7 @@ asn1_TYPE_descriptor_t asn1_DEF_UniversalString = {
/
sizeof
(
asn1_DEF_UniversalString_tags
[
0
]),
1
,
/* Single UNIVERSAL tag may be implicitly overriden */
-
1
,
/* Both ways are fine */
0
/* No specifics */
};
...
...
@@ -35,6 +36,9 @@ UniversalString_print(asn1_TYPE_descriptor_t *td, const void *sptr, int ilevel,
char
scratch
[
128
];
/* Scratchpad buffer */
char
*
p
;
(
void
)
td
;
/* Unused argument */
(
void
)
ilevel
;
/* Unused argument */
if
(
!
st
||
!
st
->
buf
)
return
cb
(
"<absent>"
,
8
,
app_key
);
wchar
=
(
uint32_t
*
)
st
->
buf
;
...
...
skeletons/VideotexString.c
View file @
d9bd775a
...
...
@@ -23,5 +23,6 @@ asn1_TYPE_descriptor_t asn1_DEF_VideotexString = {
/
sizeof
(
asn1_DEF_VideotexString_tags
[
0
]),
1
,
/* Single UNIVERSAL tag may be implicitly overriden */
-
1
,
/* Both ways are fine */
0
/* No specifics */
};
skeletons/VisibleString.c
View file @
d9bd775a
...
...
@@ -23,6 +23,7 @@ asn1_TYPE_descriptor_t asn1_DEF_VisibleString = {
/
sizeof
(
asn1_DEF_VisibleString_tags
[
0
]),
1
,
/* Single UNIVERSAL tag may be implicitly overriden */
-
1
,
/* Both ways are fine */
0
/* No specifics */
};
...
...
skeletons/ber_decoder.c
View file @
d9bd775a
...
...
@@ -210,7 +210,7 @@ ber_check_tags(asn1_TYPE_descriptor_t *head, ber_dec_ctx_t *ctx,
ADVANCE
(
tag_len
+
len_len
);
limit_len
-=
(
tag_len
+
len_len
);
if
(
size
>
limit_len
)
{
if
(
(
ssize_t
)
size
>
limit_len
)
{
/*
* Make sure that we won't consume more bytes
* from the large buffer than the inferred limit.
...
...
skeletons/ber_tlv_length.c
View file @
d9bd775a
...
...
@@ -24,7 +24,7 @@ ber_fetch_length(int _is_constructed, void *bufptr, size_t size,
return
1
;
}
else
{
ber_tlv_len_t
len
;
s
s
ize_t
skipped
;
size_t
skipped
;
if
(
_is_constructed
&&
oct
==
0x80
)
{
*
len_r
=
-
1
;
/* Indefinite length */
...
...
@@ -65,7 +65,7 @@ ber_skip_length(int _is_constructed, void *ptr, size_t size) {
ber_tlv_len_t
vlen
;
/* Length of V in TLV */
ssize_t
tl
;
/* Length of L in TLV */
ssize_t
ll
;
/* Length of L in TLV */
s
s
ize_t
skip
;
size_t
skip
;
/*
* Determine the size of L in TLV.
...
...
@@ -118,7 +118,7 @@ ber_skip_length(int _is_constructed, void *ptr, size_t size) {
ssize_t
der_tlv_length_serialize
(
ber_tlv_len_t
len
,
void
*
bufp
,
size_t
size
)
{
s
s
ize_t
computed_size
;
/* Size of len encoding */
size_t
computed_size
;
/* Size of len encoding */
uint8_t
*
buf
=
bufp
;
uint8_t
*
end
;
int
i
;
...
...
skeletons/ber_tlv_tag.c
View file @
d9bd775a
...
...
@@ -10,7 +10,7 @@ ssize_t
ber_fetch_tag
(
void
*
ptr
,
size_t
size
,
ber_tlv_tag_t
*
tag_r
)
{
ber_tlv_tag_t
val
;
ber_tlv_tag_t
tclass
;
s
s
ize_t
skipped
;
size_t
skipped
;
if
(
size
==
0
)
return
0
;
...
...
@@ -61,7 +61,7 @@ ber_tlv_tag_fwrite(ber_tlv_tag_t tag, FILE *f) {
ssize_t
ret
;
ret
=
ber_tlv_tag_snprint
(
tag
,
buf
,
sizeof
(
buf
));
if
(
ret
>=
sizeof
(
buf
)
||
ret
<
2
)
{
if
(
ret
>=
(
ssize_t
)
sizeof
(
buf
)
||
ret
<
2
)
{
errno
=
EPERM
;
return
-
1
;
}
...
...
@@ -103,7 +103,7 @@ der_tlv_tag_serialize(ber_tlv_tag_t tag, void *bufp, size_t size) {
ber_tlv_tag_t
tval
=
BER_TAG_VALUE
(
tag
);
uint8_t
*
buf
=
bufp
;
uint8_t
*
end
;
s
s
ize_t
computed_size
;
size_t
computed_size
;
int
i
;
if
(
tval
<=
30
)
{
...
...
skeletons/constr_CHOICE.c
View file @
d9bd775a
...
...
@@ -11,7 +11,7 @@
* (ctx->left) indicates the number of bytes _transferred_ for the structure.
* (size) contains the number of bytes in the buffer passed.
*/
#define LEFT ((size<ctx->left)?size:ctx->left)
#define LEFT ((size<
(size_t)
ctx->left)?size:ctx->left)
/*
* If the subprocessor function returns with an indication that it wants
...
...
@@ -24,7 +24,7 @@
* if the V processor returns with "want more data" even if the buffer
* contains way more data than the V processor have seen.
*/
#define SIZE_VIOLATION (ctx->left >= 0 && ctx->left <= size)
#define SIZE_VIOLATION (ctx->left >= 0 &&
(size_t)
ctx->left <= size)
/*
* This macro "eats" the part of the buffer which is definitely "consumed",
...
...
skeletons/constr_SEQUENCE.c
View file @
d9bd775a
...
...
@@ -9,7 +9,7 @@
* (ctx->left) indicates the number of bytes _transferred_ for the structure.
* (size) contains the number of bytes in the buffer passed.
*/
#define LEFT ((size<ctx->left)?size:ctx->left)
#define LEFT ((size<
(size_t)
ctx->left)?size:ctx->left)
/*
* If the subprocessor function returns with an indication that it wants
...
...
@@ -22,7 +22,7 @@
* if the V processor returns with "want more data" even if the buffer
* contains way more data than the V processor have seen.
*/
#define SIZE_VIOLATION (ctx->left >= 0 && ctx->left <= size)
#define SIZE_VIOLATION (ctx->left >= 0 &&
(size_t)
ctx->left <= size)
/*
* This macro "eats" the part of the buffer which is definitely "consumed",
...
...
skeletons/constr_SEQUENCE_OF.c
View file @
d9bd775a
...
...
@@ -68,7 +68,7 @@ SEQUENCE_OF_encode_der(asn1_TYPE_descriptor_t *sd, void *ptr,
encoding_size
+=
erval
.
encoded
;
}
if
(
computed_size
!=
encoding_size
)
{
if
(
computed_size
!=
(
size_t
)
encoding_size
)
{
/*
* Encoded size is not equal to the computed size.
*/
...
...
skeletons/constr_SET.c
View file @
d9bd775a
...
...
@@ -11,7 +11,7 @@
* (ctx->left) indicates the number of bytes _transferred_ for the structure.
* (size) contains the number of bytes in the buffer passed.
*/
#define LEFT ((size<ctx->left)?size:ctx->left)
#define LEFT ((size<
(size_t)
ctx->left)?size:ctx->left)
/*
* If the subprocessor function returns with an indication that it wants
...
...
@@ -24,7 +24,7 @@
* if the V processor returns with "want more data" even if the buffer
* contains way more data than the V processor have seen.
*/
#define SIZE_VIOLATION (ctx->left >= 0 && ctx->left <= size)
#define SIZE_VIOLATION (ctx->left >= 0 &&
(size_t)
ctx->left <= size)
/*
* This macro "eats" the part of the buffer which is definitely "consumed",
...
...
skeletons/constr_SET_OF.c
View file @
d9bd775a
...
...
@@ -10,7 +10,7 @@
* (ctx->left) indicates the number of bytes _transferred_ for the structure.
* (size) contains the number of bytes in the buffer passed.
*/
#define LEFT ((size<ctx->left)?size:ctx->left)
#define LEFT ((size<
(size_t)
ctx->left)?size:ctx->left)
/*
* If the subprocessor function returns with an indication that it wants
...
...
@@ -23,7 +23,7 @@
* if the V processor returns with "want more data" even if the buffer
* contains way more data than the V processor have seen.
*/
#define SIZE_VIOLATION (ctx->left != -1 && ctx->left <= size)
#define SIZE_VIOLATION (ctx->left != -1 &&
(size_t)
ctx->left <= size)
/*
* This macro "eats" the part of the buffer which is definitely "consumed",
...
...
@@ -178,7 +178,7 @@ SET_OF_decode_ber(asn1_TYPE_descriptor_t *sd,
}
/* Outmost tag may be unknown and cannot be fetched/compared */
if
(
element
->
tag
!=
-
1
)
{
if
(
element
->
tag
!=
(
ber_tlv_tag_t
)
-
1
)
{
if
(
BER_TAGS_EQUAL
(
tlv_tag
,
element
->
tag
))
{
/*
* The new list member of expected type has arrived.
...
...
@@ -334,7 +334,7 @@ SET_OF_encode_der(asn1_TYPE_descriptor_t *sd, void *ptr,
computed_size
+=
erval
.
encoded
;
/* Compute maximum encoding's size */
if
(
max_encoded_len
<
erval
.
encoded
)
if
(
max_encoded_len
<
(
size_t
)
erval
.
encoded
)
max_encoded_len
=
erval
.
encoded
;
}
...
...
@@ -429,7 +429,7 @@ SET_OF_encode_der(asn1_TYPE_descriptor_t *sd, void *ptr,
}
FREEMEM
(
encoded_els
);
if
(
ret
||
computed_size
!=
encoding_size
)
{
if
(
ret
||
computed_size
!=
(
size_t
)
encoding_size
)
{
/*
* Standard callback failed, or
* encoded size is not equal to the computed size.
...
...
skeletons/constraints.c
View file @
d9bd775a
...
...
@@ -4,6 +4,12 @@
int
asn_generic_no_constraint
(
asn1_TYPE_descriptor_t
*
type_descriptor
,
const
void
*
struct_ptr
,
asn_app_consume_bytes_f
*
cb
,
void
*
key
)
{
(
void
)
type_descriptor
;
/* Unused argument */
(
void
)
struct_ptr
;
/* Unused argument */
(
void
)
cb
;
/* Unused argument */
(
void
)
key
;
/* Unused argument */
/* Nothing to check */
return
0
;
}
...
...
@@ -11,6 +17,12 @@ asn_generic_no_constraint(asn1_TYPE_descriptor_t *type_descriptor,
int
asn_generic_unknown_constraint
(
asn1_TYPE_descriptor_t
*
type_descriptor
,
const
void
*
struct_ptr
,
asn_app_consume_bytes_f
*
cb
,
void
*
key
)
{
(
void
)
type_descriptor
;
/* Unused argument */
(
void
)
struct_ptr
;
/* Unused argument */
(
void
)
cb
;
/* Unused argument */
(
void
)
key
;
/* Unused argument */
/* Unknown how to check */
return
0
;
}
...
...
@@ -86,7 +98,7 @@ _asn_i_log_error(asn_app_consume_bytes_f *cb, void *key, const char *fmt, ...) {
/* Fall through */
}
if
(
ret
<
sizeof
(
buf
))
{
if
(
ret
<
(
ssize_t
)
sizeof
(
buf
))
{
cb
(
buf
,
ret
,
key
);
return
;
}
...
...
@@ -102,7 +114,7 @@ _asn_i_log_error(asn_app_consume_bytes_f *cb, void *key, const char *fmt, ...) {
va_start
(
ap
,
fmt
);
ret
=
vsnprintf
(
buf
,
len
,
fmt
,
ap
);
va_end
(
ap
);
if
(
ret
<
0
||
ret
>=
len
)
{
if
(
ret
<
0
||
ret
>=
(
ssize_t
)
len
)
{
ret
=
sizeof
(
"<broken vsnprintf>"
)
-
1
;
memcpy
(
buf
,
"<broken vsnprintf>"
,
ret
+
1
);
}
...
...
skeletons/der_encoder.c
View file @
d9bd775a
...
...
@@ -118,7 +118,7 @@ der_write_TL(ber_tlv_tag_t tag, ber_tlv_len_t len,
/* Serialize tag (T from TLV) into possibly zero-length buffer */
tmp
=
der_tlv_tag_serialize
(
tag
,
buf
,
buf_size
);
if
(
tmp
==
-
1
||
tmp
>
sizeof
(
buf
))
return
-
1
;
if
(
tmp
==
-
1
||
tmp
>
(
ssize_t
)
sizeof
(
buf
))
return
-
1
;
size
+=
tmp
;
/* Serialize length (L from TLV) into possibly zero-length buffer */
...
...
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