From 71d827dd89b78424f5d89e712e0a189ca2fcc71d Mon Sep 17 00:00:00 2001 From: Kenny Millington Date: Mon, 18 Oct 2010 11:50:07 +0100 Subject: [PATCH] Allow dyn_file_func to trigger a FileNotFound error. Signed-off-by: Michael P. Soulier --- tftpy/TftpStates.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tftpy/TftpStates.py b/tftpy/TftpStates.py index fdc4566..c521e51 100644 --- a/tftpy/TftpStates.py +++ b/tftpy/TftpStates.py @@ -593,6 +593,12 @@ class TftpStateServerRecvRRQ(TftpState): log.debug("No such file %s but using dyn_file_func" % path) self.context.fileobj = \ self.context.dyn_file_func(self.context.file_to_transfer) + + if self.context.fileobj is None: + log.debug("dyn_file_func returned 'None', treating as " + "FileNotFound") + self.sendError(TftpErrors.FileNotFound) + raise TftpException, "File not found: %s" % path else: self.sendError(TftpErrors.FileNotFound) raise TftpException, "File not found: %s" % path