diff options
author | Jan Kiszka <jan.kiszka@siemens.com> | 2009-06-24 14:42:29 +0200 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2009-06-29 08:52:47 -0500 |
commit | af6dd41058af018870db38ec951c6229221a77cc (patch) | |
tree | 401fef4af96c2f612ec8544e21d3aad17cbea936 | |
parent | 37fe84b660d8030cd7ce1e082b3a50a485e844dc (diff) | |
download | slirp-af6dd41058af018870db38ec951c6229221a77cc.zip slirp-af6dd41058af018870db38ec951c6229221a77cc.tar.gz slirp-af6dd41058af018870db38ec951c6229221a77cc.tar.bz2 |
slirp: tftp: Cleanup tftp_prefix check
Perform check for set prefix early (if it's not given, tftp is disabled)
and drop redundant second check.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
-rw-r--r-- | tftp.c | 15 |
1 files changed, 7 insertions, 8 deletions
@@ -284,6 +284,12 @@ static void tftp_handle_rrq(struct tftp_t *tp, int pktlen) spt = &tftp_sessions[s]; + /* unspecifed prefix means service disabled */ + if (!tftp_prefix) { + tftp_send_error(spt, 2, "Access violation", tp); + return; + } + src = tp->x.tp_buf; dst = spt->filename; n = pktlen - ((uint8_t *)&tp->x.tp_buf[0] - (uint8_t *)tp); @@ -329,13 +335,6 @@ static void tftp_handle_rrq(struct tftp_t *tp, int pktlen) return; } - /* only allow exported prefixes */ - - if (!tftp_prefix) { - tftp_send_error(spt, 2, "Access violation", tp); - return; - } - /* check if the file exists */ if (tftp_read_data(spt, 0, spt->filename, 0) < 0) { @@ -366,7 +365,7 @@ static void tftp_handle_rrq(struct tftp_t *tp, int pktlen) int tsize = atoi(value); struct stat stat_p; - if (tsize == 0 && tftp_prefix) { + if (tsize == 0) { char buffer[1024]; int len; |