summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xlib/tftpy.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/tftpy.py b/lib/tftpy.py
index 8ee5808..fe2018e 100755
--- a/lib/tftpy.py
+++ b/lib/tftpy.py
@@ -914,9 +914,10 @@ class TftpServerHandler(TftpSession):
def send_dat(self, resend=False):
"""This method reads sends a DAT packet based on what is in self.buffer."""
if not resend:
- self.buffer = self.fileobj.read(int(self.options['blksize']))
+ blksize = int(self.options['blksize'])
+ self.buffer = self.fileobj.read(blksize)
logger.debug("Read %d bytes into buffer" % len(self.buffer))
- if not self.buffer:
+ if self.buffer == "" or self.buffer < blksize:
logger.info("Reached EOF on file %s" % self.filename)
self.state.state = 'fin'
self.blocknumber += 1