diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 2007-08-28 14:03:52 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 2007-08-28 14:03:52 +0000 |
commit | 4d11115798b72d14794c2e05d0f28e6c60a6a593 (patch) | |
tree | 2aebc579837fe247970729c9a9cbb5aaed7eeff8 /cpukit/ftpd | |
parent | 2007-07-31 Joel Sherrill <joel.sherrill@OARcorp.com> (diff) | |
download | rtems-4d11115798b72d14794c2e05d0f28e6c60a6a593.tar.bz2 |
2007-08-28 Joel Sherrill <joel.sherrill@OARcorp.com>
PR 1256/networking
* ftpd/ftpd.c, sapi/src/io.c: Fix unaligned access.
Diffstat (limited to 'cpukit/ftpd')
-rw-r--r-- | cpukit/ftpd/ftpd.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/cpukit/ftpd/ftpd.c b/cpukit/ftpd/ftpd.c index dc2153793d..bdb406b39e 100644 --- a/cpukit/ftpd/ftpd.c +++ b/cpukit/ftpd/ftpd.c @@ -1432,13 +1432,19 @@ command_port(FTPD_SessionInfo_t *info, char const *args) if(NUM_FIELDS == n) { int i; - uint8_t b[NUM_FIELDS]; + union { + uint8_t b[NUM_FIELDS]; + struct { + uint32_t ip; + uint16_t port; + }; + } ip_info; for(i = 0; i < NUM_FIELDS; ++i) { if(a[i] > 255) break; - b[i] = (uint8_t)a[i]; + ip_info.b[i] = (uint8_t)a[i]; } if(i == NUM_FIELDS) @@ -1446,11 +1452,10 @@ command_port(FTPD_SessionInfo_t *info, char const *args) /* Note: while it contradicts with RFC959, we don't allow PORT command * to specify IP address different than those of the originating client * for the sake of safety. */ - uint32_t const *ip = (uint32_t *)b; - if(*ip == info->def_addr.sin_addr.s_addr) + if (ip_info.ip == info->def_addr.sin_addr.s_addr) { - info->data_addr.sin_addr.s_addr = *ip; - info->data_addr.sin_port = *(uint16_t *)(b + 4); + info->data_addr.sin_addr.s_addr = ip_info.ip; + info->data_addr.sin_port = ip_info.port; info->data_addr.sin_family = AF_INET; memset(info->data_addr.sin_zero, 0, sizeof(info->data_addr.sin_zero)); |