diff options
author | Enrico Scholz <enrico.scholz@sigma-chemnitz.de> | 2022-08-30 09:38:15 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2022-09-12 12:09:45 +0200 |
commit | a21b7ddc5a90868eda665c69004c43b37beea6ca (patch) | |
tree | 7af465fe5654ffd7eefb044ac0a088ef1efb04f1 | |
parent | 32867e6d6e49cc02057476cd4fbeb726ca1ee9e4 (diff) | |
download | barebox-a21b7ddc5a90868eda665c69004c43b37beea6ca.tar.gz barebox-a21b7ddc5a90868eda665c69004c43b37beea6ca.tar.xz |
tftp: accept OACK + DATA datagrams only in certain states
These packets are valid in certain points of the transfer only and
accepting them too early or too late can corrupt internal states.
Reject them when they are unexpected.
Signed-off-by: Enrico Scholz <enrico.scholz@sigma-chemnitz.de>
Link: https://lore.barebox.org/20220830073816.2694734-21-enrico.scholz@sigma-chemnitz.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r-- | fs/tftp.c | 12 |
1 files changed, 12 insertions, 0 deletions
@@ -717,6 +717,12 @@ static void tftp_recv(struct file_priv *priv, break; case TFTP_OACK: + if (priv->state != STATE_RRQ && priv->state != STATE_WRQ) { + pr_warn("OACK packet in %s state\n", + tftp_states[priv->state]); + break; + } + priv->tftp_con->udp->uh_dport = uh_sport; if (tftp_parse_oack(priv, pkt, len) < 0) { @@ -745,6 +751,12 @@ static void tftp_recv(struct file_priv *priv, break; } + if (priv->state != STATE_RDATA) { + pr_warn("DATA packet in %s state\n", + tftp_states[priv->state]); + break; + } + tftp_handle_data(priv, block, pkt + 2, len); break; |