jborean93 / smbprotocol

Python SMBv2 and v3 Client
MIT License
316 stars 73 forks source link

Fix negotiate request context padding #201

Closed jborean93 closed 1 year ago

jborean93 commented 1 year ago

When using a negotiate request with a hostname that is a multiple of 8 bytes the code will add 8 extra padding bytes. While this works on some servers others are stricter and can fail the request. This commit fixes up the padding to ensure no padding is used if the length of a context request aligns with the 8 byte boundary it is in.

Fixes: https://github.com/jborean93/smbprotocol/issues/199

codecov[bot] commented 1 year ago

Codecov Report

Merging #201 (4c7bfde) into master (dabafb9) will decrease coverage by 0.00%. The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master     #201      +/-   ##
==========================================
- Coverage   99.09%   99.09%   -0.01%     
==========================================
  Files          24       24              
  Lines        5079     5077       -2     
==========================================
- Hits         5033     5031       -2     
  Misses         46       46              
Flag Coverage Δ
macOS 68.20% <100.00%> (+0.02%) :arrow_up:
py3.10 99.07% <100.00%> (-0.01%) :arrow_down:
py3.7 99.07% <100.00%> (-0.01%) :arrow_down:
py3.8 99.07% <100.00%> (-0.01%) :arrow_down:
py3.9 99.09% <100.00%> (-0.01%) :arrow_down:
ubuntu 96.78% <100.00%> (-0.01%) :arrow_down:
windows 99.01% <100.00%> (-0.01%) :arrow_down:
x64 99.09% <100.00%> (-0.01%) :arrow_down:
x86 99.01% <100.00%> (-0.01%) :arrow_down:

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/smbprotocol/connection.py 99.84% <100.00%> (-0.01%) :arrow_down:

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.