mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-08 10:13:56 -06:00
Change -tftp option to take a root directory, by Anthony Liguori.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@2441 c046a42c-6fe2-441c-8c8c-71466251a162
This commit is contained in:
parent
1f697db9c3
commit
0db1137dbf
3 changed files with 15 additions and 10 deletions
12
slirp/tftp.c
12
slirp/tftp.c
|
@ -102,8 +102,15 @@ static int tftp_read_data(struct tftp_session *spt, u_int16_t block_nr,
|
|||
{
|
||||
int fd;
|
||||
int bytes_read = 0;
|
||||
char buffer[1024];
|
||||
int n;
|
||||
|
||||
fd = open(spt->filename, O_RDONLY | O_BINARY);
|
||||
n = snprintf(buffer, sizeof(buffer), "%s/%s",
|
||||
tftp_prefix, spt->filename);
|
||||
if (n >= sizeof(buffer))
|
||||
return -1;
|
||||
|
||||
fd = open(buffer, O_RDONLY | O_BINARY);
|
||||
|
||||
if (fd < 0) {
|
||||
return -1;
|
||||
|
@ -325,8 +332,7 @@ static void tftp_handle_rrq(struct tftp_t *tp, int pktlen)
|
|||
|
||||
/* only allow exported prefixes */
|
||||
|
||||
if (!tftp_prefix
|
||||
|| (strncmp(spt->filename, tftp_prefix, strlen(tftp_prefix)) != 0)) {
|
||||
if (!tftp_prefix) {
|
||||
tftp_send_error(spt, 2, "Access violation", tp);
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue