summaryrefslogtreecommitdiff
path: root/slirp/tftp.c
diff options
context:
space:
mode:
authorJan Kiszka <jan.kiszka@siemens.com>2009-06-24 14:42:29 +0200
committerAnthony Liguori <aliguori@us.ibm.com>2009-06-29 08:52:47 -0500
commitf8e3cbd3b5d1c76ec295cfc8858fd696188c270d (patch)
treea26d157b96cdd693daeb5ebf034b846fa8035eb6 /slirp/tftp.c
parentee9be587351dc1d53c8b0a07854a36ad5f6b6383 (diff)
downloadqemu-f8e3cbd3b5d1c76ec295cfc8858fd696188c270d.tar.gz
qemu-f8e3cbd3b5d1c76ec295cfc8858fd696188c270d.tar.bz2
qemu-f8e3cbd3b5d1c76ec295cfc8858fd696188c270d.zip
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>
Diffstat (limited to 'slirp/tftp.c')
-rw-r--r--slirp/tftp.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/slirp/tftp.c b/slirp/tftp.c
index 3358e2b230..5d5614adc3 100644
--- a/slirp/tftp.c
+++ b/slirp/tftp.c
@@ -287,6 +287,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);
@@ -333,13 +339,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) {
@@ -370,7 +369,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;