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
27d7049f
Commit
27d7049f
authored
Sep 29, 2004
by
Lev Walkin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added tests for length limit
parent
1cbd222a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
4 deletions
+21
-4
skeletons/tests/check-length.c
skeletons/tests/check-length.c
+21
-4
No files found.
skeletons/tests/check-length.c
View file @
27d7049f
...
...
@@ -53,12 +53,12 @@ check(int size) {
}
buf_off
=
0
;
erval
=
der_encode
(
&
asn
1
_DEF_OCTET_STRING
,
erval
=
der_encode
(
&
asn_DEF_OCTET_STRING
,
os
,
write_to_buf
,
0
);
assert
(
erval
.
encoded
==
buf_off
);
assert
(
buf_off
>
size
);
rval
=
ber_decode
(
&
asn1
_DEF_OCTET_STRING
,
(
void
**
)
&
nos
,
buf
,
buf_off
);
rval
=
ber_decode
(
0
,
&
asn
_DEF_OCTET_STRING
,
(
void
**
)
&
nos
,
buf
,
buf_off
);
assert
(
rval
.
code
==
RC_OK
);
assert
(
rval
.
consumed
==
buf_off
);
...
...
@@ -76,12 +76,17 @@ check(int size) {
}
asn
1_DEF_OCTET_STRING
.
free_struct
(
&
asn1
_DEF_OCTET_STRING
,
os
,
0
);
asn
1_DEF_OCTET_STRING
.
free_struct
(
&
asn1
_DEF_OCTET_STRING
,
nos
,
0
);
asn
_DEF_OCTET_STRING
.
free_struct
(
&
asn
_DEF_OCTET_STRING
,
os
,
0
);
asn
_DEF_OCTET_STRING
.
free_struct
(
&
asn
_DEF_OCTET_STRING
,
nos
,
0
);
}
int
main
()
{
uint8_t
buf1
[]
=
{
0x85
,
0x00
,
0x01
,
0x02
,
0x03
,
0x04
};
uint8_t
buf2
[]
=
{
0x85
,
0x00
,
0x7f
,
0xff
,
0x03
,
0x04
};
uint8_t
buf3
[]
=
{
0x85
,
0x00
,
0x7f
,
0xff
,
0xff
,
0x04
};
ber_tlv_len_t
tlv_len
;
ssize_t
ret
;
int
i
;
for
(
i
=
0
;
i
<
66000
;
i
++
)
{
...
...
@@ -89,5 +94,17 @@ main() {
check
(
i
);
}
ret
=
ber_fetch_length
(
0
,
buf1
,
sizeof
(
buf1
),
&
tlv_len
);
printf
(
"ret=%d, len=%d
\n
"
,
ret
,
tlv_len
);
assert
(
ret
==
sizeof
(
buf1
));
ret
=
ber_fetch_length
(
0
,
buf2
,
sizeof
(
buf2
),
&
tlv_len
);
printf
(
"ret=%d, len=%d
\n
"
,
ret
,
tlv_len
);
assert
(
ret
==
sizeof
(
buf2
));
ret
=
ber_fetch_length
(
0
,
buf3
,
sizeof
(
buf3
),
&
tlv_len
);
printf
(
"ret=%d
\n
"
,
ret
);
assert
(
ret
==
-
1
);
return
0
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment