From 8c54437357fde5fc3e3679f4c7811d51276e6313 Mon Sep 17 00:00:00 2001 From: "Joseph C. Lehner" Date: Wed, 10 Aug 2016 12:33:08 +0200 Subject: [PATCH] Fix crash related to arg->file_remote --- tftp.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tftp.c b/tftp.c index 2f65738..7da210b 100644 --- a/tftp.c +++ b/tftp.c @@ -234,18 +234,24 @@ int tftp_put(struct nmrpd_args *args) ssize_t len, last_len; int fd, sock, ret, timeout, errors, ackblock; char rx[TFTP_PKT_SIZE], tx[TFTP_PKT_SIZE]; + const char *file_remote = args->file_remote; sock = -1; ret = -1; if (!strcmp(args->file_local, "-")) { fd = STDIN_FILENO; + if (!file_remote) { + file_remote = "firmware"; + } } else { fd = open(args->file_local, O_RDONLY | O_BINARY); if (fd < 0) { perror("open"); ret = fd; goto cleanup; + } else if (!file_remote) { + file_remote = args->file_local; } } @@ -271,7 +277,7 @@ int tftp_put(struct nmrpd_args *args) /* Not really, but this way the loop sends our WRQ before receiving */ timeout = 1; - pkt_mkwrq(tx, args->file_remote); + pkt_mkwrq(tx, file_remote); do { if (!timeout && pkt_num(rx) == ACK) { -- 2.25.1