Commit f8e3cbd3b5d1c76ec295cfc8858fd696188c270d
Committed by
Anthony Liguori
1 parent
ee9be587
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>
Showing
1 changed file
with
7 additions
and
8 deletions
slirp/tftp.c
... | ... | @@ -287,6 +287,12 @@ static void tftp_handle_rrq(struct tftp_t *tp, int pktlen) |
287 | 287 | |
288 | 288 | spt = &tftp_sessions[s]; |
289 | 289 | |
290 | + /* unspecifed prefix means service disabled */ | |
291 | + if (!tftp_prefix) { | |
292 | + tftp_send_error(spt, 2, "Access violation", tp); | |
293 | + return; | |
294 | + } | |
295 | + | |
290 | 296 | src = tp->x.tp_buf; |
291 | 297 | dst = spt->filename; |
292 | 298 | 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) |
333 | 339 | return; |
334 | 340 | } |
335 | 341 | |
336 | - /* only allow exported prefixes */ | |
337 | - | |
338 | - if (!tftp_prefix) { | |
339 | - tftp_send_error(spt, 2, "Access violation", tp); | |
340 | - return; | |
341 | - } | |
342 | - | |
343 | 342 | /* check if the file exists */ |
344 | 343 | |
345 | 344 | 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) |
370 | 369 | int tsize = atoi(value); |
371 | 370 | struct stat stat_p; |
372 | 371 | |
373 | - if (tsize == 0 && tftp_prefix) { | |
372 | + if (tsize == 0) { | |
374 | 373 | char buffer[1024]; |
375 | 374 | int len; |
376 | 375 | ... | ... |