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
6550fd59
Commit
6550fd59
authored
Oct 26, 2004
by
Lev Walkin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pretty-print more
parent
1e3ccbb2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
5 deletions
+19
-5
asn1c/unber.c
asn1c/unber.c
+19
-5
No files found.
asn1c/unber.c
View file @
6550fd59
...
@@ -439,6 +439,13 @@ print_V(const char *fname, FILE *fp, ber_tlv_tag_t tlv_tag, ber_tlv_len_t tlv_le
...
@@ -439,6 +439,13 @@ print_V(const char *fname, FILE *fp, ber_tlv_tag_t tlv_tag, ber_tlv_len_t tlv_le
(
etype
&
ASN_STRING_MASK
)
(
etype
&
ASN_STRING_MASK
)
||
||
(
etype
==
ASN_BASIC_OCTET_STRING
)
(
etype
==
ASN_BASIC_OCTET_STRING
)
||
/*
* AUTOMATIC TAGS or IMPLICIT TAGS in effect,
* Treat this primitive type as OCTET_STRING.
*/
(
BER_TAG_CLASS
(
tlv_tag
)
!=
ASN_TAG_CLASS_UNIVERSAL
&&
pretty_printing
)
)
&&
(
tlv_len
>
0
&&
tlv_len
<
128
*
1024
))
{
)
&&
(
tlv_len
>
0
&&
tlv_len
<
128
*
1024
))
{
vbuf
=
malloc
(
tlv_len
+
1
);
vbuf
=
malloc
(
tlv_len
+
1
);
/* Not checking is intentional */
/* Not checking is intentional */
...
@@ -450,7 +457,8 @@ print_V(const char *fname, FILE *fp, ber_tlv_tag_t tlv_tag, ber_tlv_len_t tlv_le
...
@@ -450,7 +457,8 @@ print_V(const char *fname, FILE *fp, ber_tlv_tag_t tlv_tag, ber_tlv_len_t tlv_le
if
(
!
vbuf
)
printf
(
special_format
?
" F>"
:
">"
);
if
(
!
vbuf
)
printf
(
special_format
?
" F>"
:
">"
);
/*
/*
* Print the value in binary or text form.
* Print the value in binary or text form,
* or collect the bytes into vbuf.
*/
*/
for
(
i
=
0
;
i
<
tlv_len
;
i
++
)
{
for
(
i
=
0
;
i
<
tlv_len
;
i
++
)
{
int
ch
=
fgetc
(
fp
);
int
ch
=
fgetc
(
fp
);
...
@@ -479,7 +487,7 @@ print_V(const char *fname, FILE *fp, ber_tlv_tag_t tlv_tag, ber_tlv_len_t tlv_le
...
@@ -479,7 +487,7 @@ print_V(const char *fname, FILE *fp, ber_tlv_tag_t tlv_tag, ber_tlv_len_t tlv_le
break
;
break
;
}
}
/* Fall through */
/* Fall through */
case
'<'
:
case
'>'
:
case
'&'
:
case
0x3c
:
case
0x3e
:
case
0x26
:
printf
(
"&#x%02x;"
,
ch
);
printf
(
"&#x%02x;"
,
ch
);
}
}
break
;
break
;
...
@@ -559,6 +567,8 @@ print_V(const char *fname, FILE *fp, ber_tlv_tag_t tlv_tag, ber_tlv_len_t tlv_le
...
@@ -559,6 +567,8 @@ print_V(const char *fname, FILE *fp, ber_tlv_tag_t tlv_tag, ber_tlv_len_t tlv_le
/*
/*
* If the buffer was not consumed, print it out.
* If the buffer was not consumed, print it out.
* It might be an OCTET STRING or other primitive type,
* which might actually be printable, but we need to figure it out.
*/
*/
if
(
vbuf
)
{
if
(
vbuf
)
{
int
binary
;
int
binary
;
...
@@ -566,13 +576,13 @@ print_V(const char *fname, FILE *fp, ber_tlv_tag_t tlv_tag, ber_tlv_len_t tlv_le
...
@@ -566,13 +576,13 @@ print_V(const char *fname, FILE *fp, ber_tlv_tag_t tlv_tag, ber_tlv_len_t tlv_le
/*
/*
* Check whether the data could be represented as text
* Check whether the data could be represented as text
*/
*/
binary
=
-
1
*
(
tlv_len
>>
2
);
/* Threshold is 2
5% binary */
binary
=
-
1
*
(
tlv_len
>>
3
);
/* Threshold is 12.
5% binary */
for
(
i
=
0
;
i
<
tlv_len
;
i
++
)
{
for
(
i
=
0
;
i
<
tlv_len
;
i
++
)
{
switch
(
vbuf
[
i
])
{
switch
(
vbuf
[
i
])
{
case
0x1b
:
binary
=
1
;
break
;
case
0x1b
:
binary
=
1
;
break
;
case
0x09
:
case
0x0a
:
case
0x0d
:
continue
;
case
0x09
:
case
0x0a
:
case
0x0d
:
continue
;
default:
default:
if
(
vbuf
[
i
]
<
0x20
||
(
vbuf
[
i
]
&
0x80
)
)
if
(
vbuf
[
i
]
<
0x20
||
vbuf
[
i
]
>=
0x7f
)
if
(
++
binary
>
0
)
/* Way too many */
if
(
++
binary
>
0
)
/* Way too many */
break
;
break
;
continue
;
continue
;
...
@@ -581,7 +591,11 @@ print_V(const char *fname, FILE *fp, ber_tlv_tag_t tlv_tag, ber_tlv_len_t tlv_le
...
@@ -581,7 +591,11 @@ print_V(const char *fname, FILE *fp, ber_tlv_tag_t tlv_tag, ber_tlv_len_t tlv_le
}
}
printf
(
">"
);
printf
(
">"
);
for
(
i
=
0
;
i
<
tlv_len
;
i
++
)
{
for
(
i
=
0
;
i
<
tlv_len
;
i
++
)
{
if
(
binary
>
0
||
vbuf
[
i
]
<
0x20
||
(
vbuf
[
i
]
&
0x80
))
if
(
binary
>
0
||
vbuf
[
i
]
<
0x20
||
vbuf
[
i
]
>=
0x7f
||
vbuf
[
i
]
==
0x26
/* '&' */
||
vbuf
[
i
]
==
0x3c
/* '<' */
||
vbuf
[
i
]
==
0x3e
/* '>' */
)
printf
(
"&#x%02x;"
,
vbuf
[
i
]);
printf
(
"&#x%02x;"
,
vbuf
[
i
]);
else
else
printf
(
"%c"
,
vbuf
[
i
]);
printf
(
"%c"
,
vbuf
[
i
]);
...
...
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