Giter Club home page Giter Club logo

Comments (5)

miketeo avatar miketeo commented on May 26, 2024 1

Patch has been merged and released under pysmb 1.1.23.

from pysmb.

donwayo avatar donwayo commented on May 26, 2024

I have also stumbled on this issue. It happens when the whole list of shares cannot be returned in a single response, and a second one has to be issued. The code that handles the response is in smb\base.py. The second response is parsed by readCB(read_message, **kwargs) and oddly enough the data returned in the response is trimmed by 24 bytes before and after: kwargs['data_bytes'] + data_bytes[24:data_len-24].

I've been looking for an explanation to these 24 bytes, but I haven't found an easy answer. The only thing that seems to be linked is that the ComReadAndxResponse header is also 24 bytes. (introduced in commit f6ebcd4)

I changed kwargs['data_bytes'] + data_bytes[24:data_len-24] to kwargs['data_bytes'] + data_bytes[24:data_len] and it seems to work for me, but I'm not sure if this is correct.

from pysmb.

carlosefr avatar carlosefr commented on May 26, 2024

I'm also having this issue and removing the 24-byte trim allows it to work. At first glance, it looks like the first 24 bytes are being dropped and the data_len-24 is just making sure the buffer doesn't overflow but, of course, that's not how byte slices work. I wonder if all those data_bytes[24:data_len-24] shouldn't all be just data_bytes[24:]...

Traceback (most recent call last):
  File "./pysmb-test.py", line 74, in <module>
    main()
  File "./pysmb-test.py", line 66, in main
    for entry in conn.listShares():
  File "/home/vagrant/bpstat-venv/lib64/python3.6/site-packages/smb/SMBConnection.py", line 149, in listShares
    self._pollForNetBIOSPacket(timeout)
  File "/home/vagrant/bpstat-venv/lib64/python3.6/site-packages/smb/SMBConnection.py", line 614, in _pollForNetBIOSPacket
    self.feedData(data)
  File "/home/vagrant/bpstat-venv/lib64/python3.6/site-packages/nmb/base.py", line 54, in feedData
    self._processNMBSessionPacket(self.data_nmb)
  File "/home/vagrant/bpstat-venv/lib64/python3.6/site-packages/nmb/base.py", line 75, in _processNMBSessionPacket
    self.onNMBSessionMessage(packet.flags, packet.data)
  File "/home/vagrant/bpstat-venv/lib64/python3.6/site-packages/smb/base.py", line 138, in onNMBSessionMessage
    if self._updateState(self.smb_message):
  File "/home/vagrant/bpstat-venv/lib64/python3.6/site-packages/smb/base.py", line 279, in _updateState_SMB2
    req.callback(message, **req.kwargs)
  File "/home/vagrant/bpstat-venv/lib64/python3.6/site-packages/smb/base.py", line 506, in readCB
    decodeResults(read_message.tid, kwargs['fid'], kwargs['data_bytes'] + data_bytes[24:data_len-24])
  File "/home/vagrant/bpstat-venv/lib64/python3.6/site-packages/smb/base.py", line 476, in decodeResults
    max_length, _, length = struct.unpack('<III', data_bytes[offset:offset+12])
struct.error: unpack requires a buffer of 12 bytes

from pysmb.

miketeo avatar miketeo commented on May 26, 2024

@carlosefr : Can you provide more information about your remote SMB server and OS? Thank you.

from pysmb.

carlosefr avatar carlosefr commented on May 26, 2024

I'm seeing this with OS=[Windows Server 2016 Standard 14393] Server=[Windows Server 2016 Standard 6.3] where the number of shares is around 120.

I don't see this problem in another server with OS=[Windows Server 2012 R2 Standard 9600] Server=[Windows Server 2012 R2 Standard 6.3] where there are "only" around 50 shares.

from pysmb.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.