Merge pull request #209 from rakslice/slirp_ftp_fix

fix for slirp ftp handling putting slirp placeholder address in PORT commands
This commit is contained in:
kanjitalk755 2024-10-05 21:40:59 +09:00 committed by GitHub
commit 79f2e7e8e4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -986,6 +986,7 @@ do_prompt:
case EMU_FTP: /* ftp */
*(m->m_data+m->m_len) = 0; /* NULL terminate for strstr */
if ((bptr = (char *)strstr(m->m_data, "ORT")) != NULL) {
struct socket * control_so = so;
/*
* Need to emulate the PORT command
*/
@ -1004,8 +1005,20 @@ do_prompt:
n5 = (n6 >> 8) & 0xff;
n6 &= 0xff;
laddr = ntohl(so->so_faddr.s_addr);
if (so->so_faddr.s_addr != alias_addr.s_addr) {
laddr = ntohl(so->so_faddr.s_addr);
} else {
/* local side address of control conn */
struct sockaddr_in addr;
socklen_t addrlen = sizeof(struct sockaddr_in);
if (getsockname(control_so->s, &addr, &addrlen) == 0) {
laddr = ntohl(addr.sin_addr.s_addr);
} else {
/* fall back to whatever we have for our address generally */
laddr = ntohl(our_addr.s_addr);
}
}
n1 = ((laddr >> 24) & 0xff);
n2 = ((laddr >> 16) & 0xff);