aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--networking/tftp.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/networking/tftp.c b/networking/tftp.c
index c03776459..a82415c60 100644
--- a/networking/tftp.c
+++ b/networking/tftp.c
@@ -548,15 +548,20 @@ int tftp_main(int argc, char **argv)
548 if ((cmd == 0) || (optind == argc)) { 548 if ((cmd == 0) || (optind == argc)) {
549 show_usage(); 549 show_usage();
550 } 550 }
551 if(cmd == tftp_cmd_get) 551 if(cmd == tftp_cmd_get) {
552 if(localfile == NULL) 552 if(localfile == NULL)
553 localfile = remotefile; 553 localfile = remotefile;
554 554 if(localfile && strcmp(localfile, "-") == 0) {
555 fd = fileno(stdout);
556 }
557 }
555 if(cmd == tftp_cmd_put) 558 if(cmd == tftp_cmd_put)
556 if(remotefile == NULL) 559 if(remotefile == NULL)
557 remotefile = localfile; 560 remotefile = localfile;
558 561
559 fd = open(localfile, flags, 0644); 562 if (fd==-1) {
563 fd = open(localfile, flags, 0644);
564 }
560 if (fd < 0) { 565 if (fd < 0) {
561 perror_msg_and_die("local file"); 566 perror_msg_and_die("local file");
562 } 567 }
@@ -577,7 +582,9 @@ int tftp_main(int argc, char **argv)
577 result = tftp(cmd, host, remotefile, fd, port, blocksize); 582 result = tftp(cmd, host, remotefile, fd, port, blocksize);
578 583
579#ifdef CONFIG_FEATURE_CLEAN_UP 584#ifdef CONFIG_FEATURE_CLEAN_UP
580 close(fd); 585 if (fd!=fileno(stdout)) {
586 close(fd);
587 }
581#endif 588#endif
582 return(result); 589 return(result);
583} 590}