Skip to content

Commit

Permalink
Merge pull request #33 from isi-mfurer/mf-integ
Browse files Browse the repository at this point in the history
Integrate 0.2.10
  • Loading branch information
isi-mfurer authored Jun 28, 2017
2 parents 9d75809 + 1129049 commit 3da821f
Show file tree
Hide file tree
Showing 3 changed files with 569 additions and 9 deletions.
2 changes: 1 addition & 1 deletion pike/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@
'test',
'transport',
]
__version_info__ = (0, 2, 9)
__version_info__ = (0, 2, 10)
__version__ = "{0}.{1}.{2}".format(*__version_info__)
11 changes: 3 additions & 8 deletions pike/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ def __init__(self, client, server, port=445):
self._pre_auth_integrity_hash = array.array('B', "\0"*64)
self.callbacks = {}
self.connection_future = Future()
self.credits = 1
self.credits = 0
self.client = client
self.server = server
self.port = port
Expand Down Expand Up @@ -713,18 +713,14 @@ def _prepare_outgoing(self):
remainder = 1 # assume 1 credit per command
if remainder > 0:
req.credit_charge += 1
# do credit accounting based on our calculations (MS-SMB2 3.2.5.1)
self.credits -= req.credit_charge

if req.credit_request is None:
req.credit_request = default_credit_request
if req.credit_charge > req.credit_request:
req.credit_request = req.credit_charge # try not to fall behind

if req.credit_charge > self.credits:
raise CreditError("Insufficient credits to send command. "
"Credits={0}, Charge={1}".format(self.credits,
req.credit_charge))

# since we have sufficient credits, the command will be sent now
del self._out_queue[0]

# Assign message id
Expand Down Expand Up @@ -783,7 +779,6 @@ def _dispatch_incoming(self, res):
for smb_res in res:
# TODO: move smb pa integrity and credit tracking to callbacks
self.smb3_pa_integrity(smb_res, smb_res.parent.buf[4:])
self.credits -= smb_res.credit_charge
self.credits += smb_res.credit_response

# Verify non-session-setup-response signatures
Expand Down
Loading

0 comments on commit 3da821f

Please sign in to comment.