From patchwork Sun Nov 20 17:05:17 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Thibault X-Patchwork-Id: 9438545 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D389E60235 for ; Sun, 20 Nov 2016 17:05:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C0E2D28516 for ; Sun, 20 Nov 2016 17:05:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B5F0D2896F; Sun, 20 Nov 2016 17:05:49 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 607F128516 for ; Sun, 20 Nov 2016 17:05:48 +0000 (UTC) Received: from localhost ([::1]:45660 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c8VYo-0001rA-WD for patchwork-qemu-devel@patchwork.kernel.org; Sun, 20 Nov 2016 12:05:47 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52835) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c8VYQ-0001qT-GY for qemu-devel@nongnu.org; Sun, 20 Nov 2016 12:05:23 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c8VYP-0001II-Eh for qemu-devel@nongnu.org; Sun, 20 Nov 2016 12:05:22 -0500 Received: from hera.aquilenet.fr ([2a01:474::1]:55367) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c8VYP-0001I7-8P for qemu-devel@nongnu.org; Sun, 20 Nov 2016 12:05:21 -0500 Received: from localhost (localhost [127.0.0.1]) by hera.aquilenet.fr (Postfix) with ESMTP id BFC4B99DE; Sun, 20 Nov 2016 18:05:20 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at aquilenet.fr Received: from hera.aquilenet.fr ([127.0.0.1]) by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id FrUaDPWkUBGv; Sun, 20 Nov 2016 18:05:19 +0100 (CET) Received: from var.youpi.perso.aquilenet.fr (unknown [IPv6:2a01:cb19:181:c200:3602:86ff:fe2c:6a19]) by hera.aquilenet.fr (Postfix) with ESMTPSA id 1A6499928; Sun, 20 Nov 2016 18:05:19 +0100 (CET) Received: from samy by var.youpi.perso.aquilenet.fr with local (Exim 4.88) (envelope-from ) id 1c8VYM-0002Om-9U; Sun, 20 Nov 2016 18:05:18 +0100 From: Samuel Thibault To: qemu-devel@nongnu.org Date: Sun, 20 Nov 2016 18:05:17 +0100 Message-Id: <20161120170517.9181-2-samuel.thibault@ens-lyon.org> X-Mailer: git-send-email 2.10.2 In-Reply-To: <20161120170517.9181-1-samuel.thibault@ens-lyon.org> References: <20161120170517.9181-1-samuel.thibault@ens-lyon.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a01:474::1 Subject: [Qemu-devel] [PULL] 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: jan.kiszka@siemens.com, Vincent Bernat , stefanha@redhat.com, Samuel Thibault Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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 Signed-off-by: Samuel Thibault --- slirp/tftp.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/slirp/tftp.c b/slirp/tftp.c index c185906..6907d5b 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] == '/' ||