aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2020-02-13 12:58:46 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2020-02-13 12:58:46 +0100
commit260bd21169843fc00ee294a5f75da9e53cb2bc14 (patch)
tree928a161362d3e7c37cc534f273f19874b8153ba0
parentbd8b05ba1b0901bbd6a913dfd5186ac7c8beffed (diff)
downloadbusybox-w32-260bd21169843fc00ee294a5f75da9e53cb2bc14.tar.gz
busybox-w32-260bd21169843fc00ee294a5f75da9e53cb2bc14.tar.bz2
busybox-w32-260bd21169843fc00ee294a5f75da9e53cb2bc14.zip
tftpd: show requested file name in open error message
function old new delta tftp_protocol 1902 1949 +47 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--networking/tftp.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/networking/tftp.c b/networking/tftp.c
index 04bfe844f..e74186884 100644
--- a/networking/tftp.c
+++ b/networking/tftp.c
@@ -402,9 +402,17 @@ static int tftp_protocol(
402 /* Open file (must be after changing user) */ 402 /* Open file (must be after changing user) */
403 local_fd = open(local_file, open_mode, 0666); 403 local_fd = open(local_file, open_mode, 0666);
404 if (local_fd < 0) { 404 if (local_fd < 0) {
405 /* sanitize name, it came from untrusted remote side */
406 unsigned char *p = (void *) local_file;
407 while (*p) {
408 if (*p < ' ')
409 *p = '?';
410 p++;
411 }
412 bb_perror_msg("can't open '%s'", local_file);
405 G_error_pkt_reason = ERR_NOFILE; 413 G_error_pkt_reason = ERR_NOFILE;
406 strcpy(G_error_pkt_str, "can't open file"); 414 strcpy(G_error_pkt_str, "can't open file");
407 goto send_err_pkt; 415 goto send_err_pkt_nomsg;
408 } 416 }
409/* gcc 4.3.1 would NOT optimize it out as it should! */ 417/* gcc 4.3.1 would NOT optimize it out as it should! */
410#if ENABLE_FEATURE_TFTP_BLOCKSIZE 418#if ENABLE_FEATURE_TFTP_BLOCKSIZE
@@ -721,7 +729,7 @@ static int tftp_protocol(
721 * must never resend the current DATA packet on receipt 729 * must never resend the current DATA packet on receipt
722 * of a duplicate ACK". 730 * of a duplicate ACK".
723 * DATA pkts are resent ONLY on timeout. 731 * DATA pkts are resent ONLY on timeout.
724 * Thus "goto send_again" will ba a bad mistake above. 732 * Thus "goto send_again" will be a bad mistake above.
725 * See: 733 * See:
726 * http://en.wikipedia.org/wiki/Sorcerer's_Apprentice_Syndrome 734 * http://en.wikipedia.org/wiki/Sorcerer's_Apprentice_Syndrome
727 */ 735 */
@@ -740,6 +748,7 @@ static int tftp_protocol(
740 send_err_pkt: 748 send_err_pkt:
741 if (G_error_pkt_str[0]) 749 if (G_error_pkt_str[0])
742 bb_simple_error_msg(G_error_pkt_str); 750 bb_simple_error_msg(G_error_pkt_str);
751 send_err_pkt_nomsg:
743 G.error_pkt[1] = TFTP_ERROR; 752 G.error_pkt[1] = TFTP_ERROR;
744 xsendto(socket_fd, G.error_pkt, 4 + 1 + strlen(G_error_pkt_str), 753 xsendto(socket_fd, G.error_pkt, 4 + 1 + strlen(G_error_pkt_str),
745 &peer_lsa->u.sa, peer_lsa->len); 754 &peer_lsa->u.sa, peer_lsa->len);