Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
scapy
Manage
Activity
Members
Plan
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
CodeLinaro
public-release-test-restored
platform
external
scapy
Commits
23b14bab
Commit
23b14bab
authored
7 years ago
by
Guillaume Valadon
Browse files
Options
Downloads
Patches
Plain Diff
Fix ASN1_BIT_STRING decoding error
parent
5477e210
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
scapy/asn1/asn1.py
+4
-2
4 additions, 2 deletions
scapy/asn1/asn1.py
test/regression.uts
+4
-0
4 additions, 0 deletions
test/regression.uts
with
8 additions
and
2 deletions
scapy/asn1/asn1.py
+
4
−
2
View file @
23b14bab
...
...
@@ -325,12 +325,14 @@ class ASN1_BIT_STRING(ASN1_Object):
super
(
ASN1_Object
,
self
).
__setattr__
(
name
,
value
)
def
__repr__
(
self
):
if
len
(
self
.
val
)
<=
16
:
return
"
<%s[%s] (%d unused bit%s)>
"
%
(
self
.
__dict__
.
get
(
"
name
"
,
self
.
__class__
.
__name__
),
self
.
val
.
decode
(),
self
.
unused_bits
,
"
s
"
if
self
.
unused_bits
>
1
else
""
)
v
=
plain_str
(
self
.
val
)
return
"
<%s[%s] (%d unused bit%s)>
"
%
(
self
.
__dict__
.
get
(
"
name
"
,
self
.
__class__
.
__name__
),
v
,
self
.
unused_bits
,
"
s
"
if
self
.
unused_bits
>
1
else
""
)
else
:
s
=
self
.
val_readable
if
len
(
s
)
>
20
:
s
=
s
[:
10
]
+
b
"
...
"
+
s
[
-
10
:]
return
"
<%s[%s] (%d unused bit%s)>
"
%
(
self
.
__dict__
.
get
(
"
name
"
,
self
.
__class__
.
__name__
),
s
.
decode
(),
self
.
unused_bits
,
"
s
"
if
self
.
unused_bits
>
1
else
""
)
v
=
plain_str
(
self
.
val
)
return
"
<%s[%s] (%d unused bit%s)>
"
%
(
self
.
__dict__
.
get
(
"
name
"
,
self
.
__class__
.
__name__
),
v
,
self
.
unused_bits
,
"
s
"
if
self
.
unused_bits
>
1
else
""
)
def
__str__
(
self
):
return
self
.
val_readable
def
__bytes__
(
self
):
...
...
This diff is collapsed.
Click to expand it.
test/regression.uts
+
4
−
0
View file @
23b14bab
...
...
@@ -777,6 +777,10 @@ a = ASN1_BIT_STRING("test", "value")
a
assert raw(a) == b'test'
a = ASN1_BIT_STRING(b"\xff"*16, "value")
a
assert raw(a) == b'\xff'*16
= ASN1 - ASN1_SEQUENCE
a = ASN1_SEQUENCE([ASN1_Object(1), ASN1_Object(0)])
assert a.strshow() == '# ASN1_SEQUENCE:\n <ASN1_Object[1]>\n <ASN1_Object[0]>\n'
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment