qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] tftp: fake support for netascii protocol
@ 2016-11-17 12:20 Vincent Bernat
  2016-11-17 12:22 ` Vincent Bernat
  2016-11-17 15:27 ` no-reply
  0 siblings, 2 replies; 5+ messages in thread
From: Vincent Bernat @ 2016-11-17 12:20 UTC (permalink / raw)
  To: Samuel Thibault, Jan Kiszka, qemu-devel; +Cc: Vincent Bernat

From: Vincent Bernat <vincent@bernat.im>

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

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-11-18 17:52 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-11-17 12:20 [Qemu-devel] [PATCH] tftp: fake support for netascii protocol Vincent Bernat
2016-11-17 12:22 ` Vincent Bernat
2016-11-18 17:52   ` Samuel Thibault
2016-11-17 15:27 ` no-reply
2016-11-17 15:58   ` Vincent Bernat

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).