1
0
mirror of https://github.com/moparisthebest/curl synced 2024-12-23 16:48:49 -05:00

tftp: make sure error is zero terminated before printfing it

This commit is contained in:
Daniel Stenberg 2018-05-22 10:10:39 +02:00
parent 679fa59ed8
commit 2e65a92052
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2

View File

@ -1148,8 +1148,11 @@ static CURLcode tftp_receive_packet(struct connectdata *conn)
case TFTP_EVENT_ERROR: case TFTP_EVENT_ERROR:
{ {
unsigned short error = getrpacketblock(&state->rpacket); unsigned short error = getrpacketblock(&state->rpacket);
char *str = (char *)state->rpacket.data + 4;
size_t strn = state->rbytes - 4;
state->error = (tftp_error_t)error; state->error = (tftp_error_t)error;
infof(data, "%s\n", (const char *)state->rpacket.data + 4); if(Curl_strnlen(str, strn) < strn)
infof(data, "TFTP error: %s\n", str);
break; break;
} }
case TFTP_EVENT_ACK: case TFTP_EVENT_ACK: