Fix crash related to arg->file_remote
This commit is contained in:
parent
6d108dc2ed
commit
8c54437357
1 changed files with 7 additions and 1 deletions
8
tftp.c
8
tftp.c
|
@ -234,18 +234,24 @@ int tftp_put(struct nmrpd_args *args)
|
||||||
ssize_t len, last_len;
|
ssize_t len, last_len;
|
||||||
int fd, sock, ret, timeout, errors, ackblock;
|
int fd, sock, ret, timeout, errors, ackblock;
|
||||||
char rx[TFTP_PKT_SIZE], tx[TFTP_PKT_SIZE];
|
char rx[TFTP_PKT_SIZE], tx[TFTP_PKT_SIZE];
|
||||||
|
const char *file_remote = args->file_remote;
|
||||||
|
|
||||||
sock = -1;
|
sock = -1;
|
||||||
ret = -1;
|
ret = -1;
|
||||||
|
|
||||||
if (!strcmp(args->file_local, "-")) {
|
if (!strcmp(args->file_local, "-")) {
|
||||||
fd = STDIN_FILENO;
|
fd = STDIN_FILENO;
|
||||||
|
if (!file_remote) {
|
||||||
|
file_remote = "firmware";
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
fd = open(args->file_local, O_RDONLY | O_BINARY);
|
fd = open(args->file_local, O_RDONLY | O_BINARY);
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
perror("open");
|
perror("open");
|
||||||
ret = fd;
|
ret = fd;
|
||||||
goto cleanup;
|
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 */
|
/* Not really, but this way the loop sends our WRQ before receiving */
|
||||||
timeout = 1;
|
timeout = 1;
|
||||||
|
|
||||||
pkt_mkwrq(tx, args->file_remote);
|
pkt_mkwrq(tx, file_remote);
|
||||||
|
|
||||||
do {
|
do {
|
||||||
if (!timeout && pkt_num(rx) == ACK) {
|
if (!timeout && pkt_num(rx) == ACK) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue