mirror of
https://github.com/curl/curl.git
synced 2026-05-15 05:56:19 +03:00
tftp: correct the filename length check
Reported-by: z2_ Bug: https://hackerone.com/reports/3508321 Closes #20283
This commit is contained in:
parent
8582ecf5bb
commit
db86f2de9b
1 changed files with 5 additions and 5 deletions
10
lib/tftp.c
10
lib/tftp.c
|
|
@ -697,16 +697,16 @@ static CURLcode tftp_send_first(struct tftp_conn *state,
|
|||
if(result)
|
||||
return result;
|
||||
|
||||
if(strlen(filename) > (state->blksize - strlen(mode) - 4)) {
|
||||
if(strlen(filename) + strlen(mode) + 4 > state->blksize) {
|
||||
failf(data, "TFTP filename too long");
|
||||
curlx_free(filename);
|
||||
return CURLE_TFTP_ILLEGAL; /* too long filename field */
|
||||
}
|
||||
|
||||
curl_msnprintf((char *)state->spacket.data + 2,
|
||||
state->blksize,
|
||||
"%s%c%s%c", filename, '\0', mode, '\0');
|
||||
sbytes = 4 + strlen(filename) + strlen(mode);
|
||||
sbytes = 2 +
|
||||
curl_msnprintf((char *)state->spacket.data + 2,
|
||||
state->blksize,
|
||||
"%s%c%s%c", filename, '\0', mode, '\0');
|
||||
curlx_free(filename);
|
||||
|
||||
/* optional addition of TFTP options */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue