← Commit list

63dd390fab

Daniel Stenberg
Daniel Stenberg
2026-09-17
SUCCESS Duration: 395s

Subject

tftp: verify direction in a few places

Binary

No binary (build failed)

Architecture & Compiler Flags

Architecture: x86_64-linux-gnu Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0

—

Build Log

(log yok)

Commit Diff GitHub →

lib/tftp.c+9 -0
@@ -366,6 +366,9 @@ static CURLcode tftp_tx(struct tftp_conn *state, tftp_event_t event)
char *bufptr;
bool eos;
+ if(!data->state.upload)
+ return CURLE_TFTP_ILLEGAL;
+
switch(event) {
case TFTP_EVENT_ACK:
@@ -773,10 +776,14 @@ static CURLcode tftp_send_first(struct tftp_conn *state,
break;
case TFTP_EVENT_ACK: /* Connected for transmit */
+ if(!data->state.upload)
+ return CURLE_TFTP_ILLEGAL;
result = tftp_connect_for_tx(state, event);
break;
case TFTP_EVENT_DATA: /* Connected for receive */
+ if(data->state.upload)
+ return CURLE_TFTP_ILLEGAL;
result = tftp_connect_for_rx(state, event);
break;
@@ -1077,6 +1084,8 @@ static CURLcode tftp_receive_packet(struct Curl_easy *data,
switch(state->event) {
case TFTP_EVENT_DATA:
+ if(data->state.upload)
+ return CURLE_TFTP_ILLEGAL;
/* Do not pass to the client empty or retransmitted packets */
if(state->rbytes > 4 &&
(NEXT_BLOCKNUM(state->block) == getrpacketblock(&state->rpacket))) {