Commit facf1a60 authored by Sergei Gavrikov's avatar Sergei Gavrikov Committed by Edgar E. Iglesias
Browse files

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



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: default avatarSergei Gavrikov <sergei.gavrikov@gmail.com>
Reviewed-by: default avatarStefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: default avatarEdgar E. Iglesias <edgar@axis.com>
parent 4508d81a
...@@ -311,7 +311,7 @@ static void tftp_handle_rrq(Slirp *slirp, struct tftp_t *tp, int pktlen) ...@@ -311,7 +311,7 @@ static void tftp_handle_rrq(Slirp *slirp, struct tftp_t *tp, int pktlen)
return; 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); tftp_send_error(spt, 4, "Unsupported transfer mode", tp);
return; return;
} }
...@@ -351,7 +351,7 @@ static void tftp_handle_rrq(Slirp *slirp, struct tftp_t *tp, int pktlen) ...@@ -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]; value = (const char *)&tp->x.tp_buf[k];
k += strlen(value) + 1; k += strlen(value) + 1;
if (strcmp(key, "tsize") == 0) { if (strcasecmp(key, "tsize") == 0) {
int tsize = atoi(value); int tsize = atoi(value);
struct stat stat_p; struct stat stat_p;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment