summaryrefslogtreecommitdiffstats
path: root/fs/tftp.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/tftp.c')
-rw-r--r--fs/tftp.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/fs/tftp.c b/fs/tftp.c
index e36c1c8a41..0de215e5e9 100644
--- a/fs/tftp.c
+++ b/fs/tftp.c
@@ -256,22 +256,21 @@ static void tftp_timer_reset(struct file_priv *priv)
static void tftp_recv(struct file_priv *priv,
uint8_t *pkt, unsigned len, uint16_t uh_sport)
{
- uint16_t proto;
- uint16_t *s;
+ uint16_t opcode;
/* according to RFC1350 minimal tftp packet length is 4 bytes */
if (len < 4)
return;
- len -= 2;
+ opcode = ntohs(*(uint16_t *)pkt);
- s = (uint16_t *)pkt;
- proto = *s++;
- pkt = (unsigned char *)s;
+ /* skip tftp opcode 2-byte field */
+ len -= 2;
+ pkt += 2;
- debug("%s: proto 0x%04x\n", __func__, proto);
+ debug("%s: opcode 0x%04x\n", __func__, opcode);
- switch (ntohs(proto)) {
+ switch (opcode) {
case TFTP_RRQ:
case TFTP_WRQ:
default: