2007-08-28 Joel Sherrill <joel.sherrill@OARcorp.com>

PR 1256/networking
	* ftpd/ftpd.c, sapi/src/io.c: Fix unaligned access.
This commit is contained in:
Joel Sherrill
2007-08-28 14:03:52 +00:00
parent d7d5363b0e
commit 4d11115798
3 changed files with 22 additions and 11 deletions

View File

@@ -1,3 +1,8 @@
2007-08-28 Joel Sherrill <joel.sherrill@OARcorp.com>
PR 1256/networking
* ftpd/ftpd.c, sapi/src/io.c: Fix unaligned access.
2007-07-31 Joel Sherrill <joel.sherrill@OARcorp.com>
PR 1248/networking

View File

@@ -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));

View File

@@ -136,15 +136,16 @@ rtems_status_code rtems_io_register_driver(
if ( major == 0 )
{
bool found = FALSE;
for ( major = _IO_Number_of_drivers - 1 ; major ; major-- )
if ( _IO_Driver_address_table[major].initialization_entry == 0 &&
_IO_Driver_address_table[major].open_entry == 0 )
_IO_Driver_address_table[major].open_entry == 0 ) {
found = FALSE;
break;
}
if (( major == 0 ) &&
( _IO_Driver_address_table[major].initialization_entry == 0 &&
_IO_Driver_address_table[major].open_entry == 0 ))
return RTEMS_TOO_MANY;
if ( !found )
return RTEMS_TOO_MANY;
}
if ( _IO_Driver_address_table[major].initialization_entry == 0 &&