Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TftpException: Invalid options in buffer #136

Open
QGB opened this issue Aug 24, 2022 · 0 comments
Open

TftpException: Invalid options in buffer #136

QGB opened this issue Aug 24, 2022 · 0 comments
Labels
pending Not looking at it yet

Comments

@QGB
Copy link

QGB commented Aug 24, 2022

import tftpy


client = tftpy.TftpClient('192.168.0.42', 69, options={'blksize': 8})

In [1014]: client.download('breed.bin','output.bin')
2022-08-24:09:17:49,158 INFO     [TftpContexts.py:389] Sending tftp download request to 192.168.1.3
2022-08-24:09:17:49,171 INFO     [TftpContexts.py:390]     filename -> breed.bin
2022-08-24:09:17:49,171 INFO     [TftpContexts.py:391]     options -> {'blksize': 8}
---------------------------------------------------------------------------
TftpException                             Traceback (most recent call last)
<ipython-input-1014-e736a6ad1e28> in <module>
----> 1 client.download('breed.bin','output.bin')

C:\QGB\Anaconda3\lib\site-packages\tftpy\TftpClient.py in download(self, filename, output, packethook, timeout, retries)
     60                                                  retries=retries,
     61                                                  localip=self.localip)
---> 62         self.context.start()
     63         # Download happens here
     64         self.context.end()

C:\QGB\Anaconda3\lib\site-packages\tftpy\TftpContexts.py in start(self)
    408             try:
    409                 log.debug("State is %s" % self.state)
--> 410                 self.cycle()
    411             except TftpTimeout as err:
    412                 log.error(str(err))

C:\QGB\Anaconda3\lib\site-packages\tftpy\TftpContexts.py in cycle(self)
    181
    182         # Decode it.
--> 183         recvpkt = self.factory.parse(buffer)
    184
    185         # Check for known "connection".

C:\QGB\Anaconda3\lib\site-packages\tftpy\TftpPacketFactory.py in parse(self, buffer)
     35         packet = self.__create(opcode)
     36         packet.buffer = buffer
---> 37         return packet.decode()
     38
     39     def __create(self, opcode):

C:\QGB\Anaconda3\lib\site-packages\tftpy\TftpPacketTypes.py in decode(self)
    467
    468     def decode(self):
--> 469         self.options = self.decode_options(self.buffer[2:])
    470         return self
    471

C:\QGB\Anaconda3\lib\site-packages\tftpy\TftpPacketTypes.py in decode_options(self, buffer)
     77                     length = -1
     78                 else:
---> 79                     raise TftpException("Invalid options in buffer")
     80             length += 1
     81

TftpException: Invalid options in buffer

server: mobaxterm

image

@msoulier msoulier added the pending Not looking at it yet label Nov 26, 2022
9001 added a commit to 9001/partftpy that referenced this issue Jun 16, 2024
mobaxterm sends OACK with multiple trailing nullbytes;
this looks like (and should be parsed as) null-length options,
which is invalid

the workaround is to strip superfluous trailing nullbytes

this has the potential side-effect of masking similar server bugs
(for example a lone option name without a value), but the warning
should make this apparent
9001 added a commit to 9001/partftpy that referenced this issue Jun 16, 2024
mobaxterm sends OACK with multiple trailing nullbytes;
this looks like (and should be parsed as) null-length options,
which is invalid

the workaround is to strip superfluous trailing nullbytes

this has the potential side-effect of masking similar server bugs
(for example a lone option name without a value), but the warning
should make this apparent
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pending Not looking at it yet
Projects
None yet
Development

No branches or pull requests

2 participants