From patchwork Sun Nov 20 08:41:36 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Bernat X-Patchwork-Id: 696981 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3tM4xJ185Mz9ssP for ; Sun, 20 Nov 2016 19:42:43 +1100 (AEDT) Received: from localhost ([::1]:44125 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c8Nhv-0001fY-3Y for incoming@patchwork.ozlabs.org; Sun, 20 Nov 2016 03:42:39 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38213) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c8NhD-0001J2-2a for qemu-devel@nongnu.org; Sun, 20 Nov 2016 03:41:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c8Nh9-00068n-W9 for qemu-devel@nongnu.org; Sun, 20 Nov 2016 03:41:55 -0500 Received: from bart.luffy.cx ([78.47.78.131]:56948) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1c8Nh9-00067n-QY for qemu-devel@nongnu.org; Sun, 20 Nov 2016 03:41:51 -0500 Received: from bart.luffy.cx (localhost [127.0.0.1]) by bart.luffy.cx (Postfix) with ESMTP id 5918814174; Sun, 20 Nov 2016 09:41:48 +0100 (CET) Received: from neo.luffy.cx (40.245.61.188.dynamic.wline.res.cust.swisscom.ch [188.61.245.40]) by bart.luffy.cx (Postfix) with ESMTPS id 2FC5E1400D; Sun, 20 Nov 2016 09:41:48 +0100 (CET) Received: by neo.luffy.cx (Postfix, from userid 500) id E47F8490; Sun, 20 Nov 2016 09:41:47 +0100 (CET) From: Vincent Bernat To: Samuel Thibault , Thomas Huth , qemu-devel@nongnu.org, Jan Kiszka , Stefan Hajnoczi Date: Sun, 20 Nov 2016 09:41:36 +0100 Message-Id: <20161120084136.721-1-Vincent.Bernat@exoscale.ch> X-Mailer: git-send-email 2.10.2 In-Reply-To: <20161119223003.GD10378@var.home> References: <20161119223003.GD10378@var.home> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x [fuzzy] X-Received-From: 78.47.78.131 Subject: [Qemu-devel] [v2] tftp: fake support for netascii protocol X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Vincent Bernat Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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. Signed-off-by: Vincent Bernat Reviewed-by: Thomas Huth --- slirp/tftp.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/slirp/tftp.c b/slirp/tftp.c index c1859066ccb2..6907d5b92074 100644 --- a/slirp/tftp.c +++ b/slirp/tftp.c @@ -26,6 +26,7 @@ #include "slirp.h" #include "qemu-common.h" #include "qemu/cutils.h" +#include "qemu/log.h" static inline int tftp_session_in_use(struct tftp_session *spt) { @@ -326,13 +327,17 @@ 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) { + qemu_log_mask(LOG_UNIMP, "tftp: netascii protocol not implemented, " + "no CR-LF conversion\n"); + 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] == '/' ||