mirror of
https://github.com/eblot/pybootd.git
synced 2024-09-11 22:17:44 +03:00
Fix block number overflow
* wrap around block number on 16-bit * use positive integers for block number
This commit is contained in:
parent
bbf0b15edb
commit
f08a6cf99d
@ -263,9 +263,9 @@ class TftpConnection(object):
|
|||||||
if not self.time:
|
if not self.time:
|
||||||
self.time = now()
|
self.time = now()
|
||||||
blocksize = self.blocksize
|
blocksize = self.blocksize
|
||||||
block = self.blockNumber = self.blockNumber + 1
|
block = self.blockNumber = (self.blockNumber + 1) 0xFFFF
|
||||||
lendata = len(data)
|
lendata = len(data)
|
||||||
fmt = '!hh%ds' % lendata
|
fmt = '!hH%ds' % lendata
|
||||||
pkt = pack(fmt, self.DATA, block, data)
|
pkt = pack(fmt, self.DATA, block, data)
|
||||||
self.send(pkt)
|
self.send(pkt)
|
||||||
self.active = (len(data) == blocksize)
|
self.active = (len(data) == blocksize)
|
||||||
@ -290,8 +290,8 @@ class TftpConnection(object):
|
|||||||
def send_ack(self, pack=spack):
|
def send_ack(self, pack=spack):
|
||||||
self.log.debug('send_ack')
|
self.log.debug('send_ack')
|
||||||
block = self.blockNumber
|
block = self.blockNumber
|
||||||
self.blockNumber = self.blockNumber + 1
|
self.blockNumber = (self.blockNumber + 1) 0xFFFF
|
||||||
fmt = '!hh'
|
fmt = '!hH'
|
||||||
pkt = pack(fmt, self.ACK, block)
|
pkt = pack(fmt, self.ACK, block)
|
||||||
self.send(pkt)
|
self.send(pkt)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user