mirror of
https://github.com/sheumann/hush.git
synced 2024-12-28 07:30:23 +00:00
Patch from Ben Low <ben@titr.uow.edu.au> to allow tftp to work
with stdin as well as stdout.
This commit is contained in:
parent
9fe5f98de4
commit
744ec1d549
@ -548,17 +548,13 @@ int tftp_main(int argc, char **argv)
|
|||||||
if ((cmd == 0) || (optind == argc)) {
|
if ((cmd == 0) || (optind == argc)) {
|
||||||
show_usage();
|
show_usage();
|
||||||
}
|
}
|
||||||
if(cmd == tftp_cmd_get) {
|
if(localfile && strcmp(localfile, "-") == 0) {
|
||||||
if(localfile == NULL)
|
fd = fileno((cmd==tftp_cmd_get)? stdin : stdout);
|
||||||
localfile = remotefile;
|
|
||||||
if(localfile && strcmp(localfile, "-") == 0) {
|
|
||||||
fd = fileno(stdout);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if(cmd == tftp_cmd_put)
|
if(localfile == NULL)
|
||||||
if(remotefile == NULL)
|
localfile = remotefile;
|
||||||
remotefile = localfile;
|
if(remotefile == NULL)
|
||||||
|
remotefile = localfile;
|
||||||
if (fd==-1) {
|
if (fd==-1) {
|
||||||
fd = open(localfile, flags, 0644);
|
fd = open(localfile, flags, 0644);
|
||||||
}
|
}
|
||||||
@ -582,7 +578,7 @@ int tftp_main(int argc, char **argv)
|
|||||||
result = tftp(cmd, host, remotefile, fd, port, blocksize);
|
result = tftp(cmd, host, remotefile, fd, port, blocksize);
|
||||||
|
|
||||||
#ifdef CONFIG_FEATURE_CLEAN_UP
|
#ifdef CONFIG_FEATURE_CLEAN_UP
|
||||||
if (fd!=fileno(stdout)) {
|
if (!(fd == fileno(stdout) || fd == fileno(stdin))) {
|
||||||
close(fd);
|
close(fd);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user