diff mbox

[PATCHv1] slirp: Use strcasecmp() to check tftp mode, tsize

Message ID alpine.DEB.2.00.1101121516290.5210@sg-desktop.belvok.com
State New
Headers show

Commit Message

Sergei Gavrikov Jan. 12, 2011, 1:57 p.m. UTC
From: Sergei Gavrikov <sergei.gavrikov@gmail.com>

According to RFC 1350 (TFTP Revision 2) the mode field can contain any
combination of upper and lower case; also RFC 2349 propagates that the
transfer size option ("tsize") is case in-sensitive too.

Current implementation of embedded TFTP server missed that what does
mess some TFTP clients. Fixed by using STRCASECMP(3) in the required
places.

Signed-off-by: Sergei Gavrikov <sergei.gavrikov@gmail.com>
Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
---
 slirp/tftp.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

Comments

Edgar E. Iglesias Jan. 13, 2011, 10:40 a.m. UTC | #1
On Wed, Jan 12, 2011 at 03:57:18PM +0200, Sergei Gavrikov wrote:
> From: Sergei Gavrikov <sergei.gavrikov@gmail.com>
> 
> According to RFC 1350 (TFTP Revision 2) the mode field can contain any
> combination of upper and lower case; also RFC 2349 propagates that the
> transfer size option ("tsize") is case in-sensitive too.
> 
> Current implementation of embedded TFTP server missed that what does
> mess some TFTP clients. Fixed by using STRCASECMP(3) in the required
> places.
> 
> Signed-off-by: Sergei Gavrikov <sergei.gavrikov@gmail.com>
> Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>

I've applied this, thanks both of you.

Cheers


> ---
>  slirp/tftp.c |    4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/slirp/tftp.c b/slirp/tftp.c
> index 55e4692..1821648 100644
> --- a/slirp/tftp.c
> +++ b/slirp/tftp.c
> @@ -311,7 +311,7 @@ static void tftp_handle_rrq(Slirp *slirp, struct tftp_t *tp, int pktlen)
>      return;
>    }
>  
> -  if (memcmp(&tp->x.tp_buf[k], "octet\0", 6) != 0) {
> +  if (strcasecmp((const char *)&tp->x.tp_buf[k], "octet") != 0) {
>        tftp_send_error(spt, 4, "Unsupported transfer mode", tp);
>        return;
>    }
> @@ -351,7 +351,7 @@ static void tftp_handle_rrq(Slirp *slirp, struct tftp_t *tp, int pktlen)
>        value = (const char *)&tp->x.tp_buf[k];
>        k += strlen(value) + 1;
>  
> -      if (strcmp(key, "tsize") == 0) {
> +      if (strcasecmp(key, "tsize") == 0) {
>  	  int tsize = atoi(value);
>  	  struct stat stat_p;
>  
>
diff mbox

Patch

diff --git a/slirp/tftp.c b/slirp/tftp.c
index 55e4692..1821648 100644
--- a/slirp/tftp.c
+++ b/slirp/tftp.c
@@ -311,7 +311,7 @@  static void tftp_handle_rrq(Slirp *slirp, struct tftp_t *tp, int pktlen)
     return;
   }
 
-  if (memcmp(&tp->x.tp_buf[k], "octet\0", 6) != 0) {
+  if (strcasecmp((const char *)&tp->x.tp_buf[k], "octet") != 0) {
       tftp_send_error(spt, 4, "Unsupported transfer mode", tp);
       return;
   }
@@ -351,7 +351,7 @@  static void tftp_handle_rrq(Slirp *slirp, struct tftp_t *tp, int pktlen)
       value = (const char *)&tp->x.tp_buf[k];
       k += strlen(value) + 1;
 
-      if (strcmp(key, "tsize") == 0) {
+      if (strcasecmp(key, "tsize") == 0) {
 	  int tsize = atoi(value);
 	  struct stat stat_p;