qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [v2] tftp: fake support for netascii protocol


From: Thomas Huth
Subject: Re: [Qemu-devel] [v2] tftp: fake support for netascii protocol
Date: Mon, 21 Nov 2016 08:35:10 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0

On 20.11.2016 09:41, Vincent Bernat wrote:
> From: Vincent Bernat <address@hidden>
> 
> 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 <address@hidden>
> ---
>  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] == '/' ||
> 

Reviewed-by: Thomas Huth <address@hidden>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]