diff options
author | Sara Golemon <pollita@php.net> | 2004-02-21 19:37:37 +0000 |
---|---|---|
committer | Sara Golemon <pollita@php.net> | 2004-02-21 19:37:37 +0000 |
commit | c23305e184412a68e5ed8e502b58fec01f52349b (patch) | |
tree | cc6fe41d3aeffdd0c0bebb86e86c71027526d0f4 /ext/ftp | |
parent | cc2dc6c85e7657583149f9b5021003b53e56ec4b (diff) | |
download | php-git-c23305e184412a68e5ed8e502b58fec01f52349b.tar.gz |
Avoid use of memcpy(), reply on struct in_addr to be right sized instead
Diffstat (limited to 'ext/ftp')
-rw-r--r-- | ext/ftp/ftp.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/ext/ftp/ftp.c b/ext/ftp/ftp.c index 8ec5a540a8..37b6520c1b 100644 --- a/ext/ftp/ftp.c +++ b/ext/ftp/ftp.c @@ -117,7 +117,7 @@ static char** ftp_genlist(ftpbuf_t *ftp, const char *cmd, const char *path TSRM /* IP and port conversion box */ union ipbox { - unsigned long l[2]; + struct in_addr ia[2]; unsigned short s[4]; unsigned char c[8]; }; @@ -775,8 +775,7 @@ ftp_pasv(ftpbuf_t *ftp, int pasv) } sin = (struct sockaddr_in *) sa; sin->sin_family = AF_INET; - /* Deal with differing integer sizes */ - memcpy(&(sin->sin_addr.s_addr), &(ipbox.c[0]), 4); + sin->sin_addr = ipbox.ia[0]; sin->sin_port = ipbox.s[2]; ftp->pasv = 2; @@ -1481,7 +1480,7 @@ ftp_getdata(ftpbuf_t *ftp TSRMLS_DC) #endif /* send the PORT */ - memcpy(&(ipbox.c[0]), &(((struct sockaddr_in*) sa)->sin_addr.s_addr), 4); + ipbox.ia[0] = ((struct sockaddr_in*) sa)->sin_addr; ipbox.s[2] = ((struct sockaddr_in*) &addr)->sin_port; sprintf(arg, "%u,%u,%u,%u,%u,%u", ipbox.c[0], ipbox.c[1], ipbox.c[2], ipbox.c[3], ipbox.c[4], ipbox.c[5]); |