From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33487) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c7Lfq-0002JC-Ux for qemu-devel@nongnu.org; Thu, 17 Nov 2016 07:20:15 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c7Lfl-0001yq-8f for qemu-devel@nongnu.org; Thu, 17 Nov 2016 07:20:14 -0500 Received: from bart.luffy.cx ([78.47.78.131]:36443) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1c7Lfl-0001t6-2b for qemu-devel@nongnu.org; Thu, 17 Nov 2016 07:20:09 -0500 From: Vincent Bernat Date: Thu, 17 Nov 2016 13:20:00 +0100 Message-Id: <20161117122000.22577-1-Vincent.Bernat@exoscale.ch> Subject: [Qemu-devel] [PATCH] tftp: fake support for netascii protocol List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Samuel Thibault , Jan Kiszka , qemu-devel@nongnu.org Cc: Vincent Bernat From: Vincent Bernat Some network equipments are requesting a file using the netascii protocol and this is not configurable. Currently, qemu's tftpd only supports the octet protocol. This commit makes it accept the netascii protocol as well but do not perform the requested transformation (LF -> CR,LF) as it would be far more complex. The current implementation is good enough. A user has always the choice to preencode the served file correctly. --- slirp/tftp.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/slirp/tftp.c b/slirp/tftp.c index c1859066ccb2..ab1c05d5d42c 100644 --- a/slirp/tftp.c +++ b/slirp/tftp.c @@ -326,13 +326,15 @@ static void tftp_handle_rrq(Slirp *slirp, struct sockaddr_storage *srcsas, return; } - if (strcasecmp(&tp->x.tp_buf[k], "octet") != 0) { + if (strcasecmp(&tp->x.tp_buf[k], "octet") == 0) { + k += 6; + } else if (strcasecmp(&tp->x.tp_buf[k], "netascii") == 0) { + k += 9; + } else { tftp_send_error(spt, 4, "Unsupported transfer mode", tp); return; } - k += 6; /* skipping octet */ - /* do sanity checks on the filename */ if (!strncmp(req_fname, "../", 3) || req_fname[strlen(req_fname) - 1] == '/' || -- 2.10.2