forked from enlightenment/efl
parent
1ba6b50042
commit
1edd7e4ffa
|
@ -409,3 +409,7 @@
|
||||||
2010-07-20 Cedric BAIL
|
2010-07-20 Cedric BAIL
|
||||||
|
|
||||||
* Improve file change detection in eet_open by checking size also.
|
* Improve file change detection in eet_open by checking size also.
|
||||||
|
|
||||||
|
2010-08-02 Cedric BAIL
|
||||||
|
|
||||||
|
* Fix bug in eet_connection code when running on 32bits machine.
|
||||||
|
|
|
@ -41,13 +41,6 @@ void * alloca (size_t);
|
||||||
|
|
||||||
#define MAGIC_EET_DATA_PACKET 0x4270ACE1
|
#define MAGIC_EET_DATA_PACKET 0x4270ACE1
|
||||||
|
|
||||||
typedef struct _Eet_Message Eet_Message;
|
|
||||||
struct _Eet_Message
|
|
||||||
{
|
|
||||||
int magic;
|
|
||||||
int size;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct _Eet_Connection
|
struct _Eet_Connection
|
||||||
{
|
{
|
||||||
Eet_Read_Cb *eet_read_cb;
|
Eet_Read_Cb *eet_read_cb;
|
||||||
|
@ -95,24 +88,24 @@ eet_connection_received(Eet_Connection *conn,
|
||||||
|
|
||||||
if (conn->size == 0)
|
if (conn->size == 0)
|
||||||
{
|
{
|
||||||
const Eet_Message *msg;
|
const int *msg;
|
||||||
size_t packet_size;
|
size_t packet_size;
|
||||||
|
|
||||||
if (size < sizeof (Eet_Message))
|
if (size < sizeof (int) * 2)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
msg = data;
|
msg = data;
|
||||||
/* Check the magic */
|
/* Check the magic */
|
||||||
if (ntohl(msg->magic) != MAGIC_EET_DATA_PACKET)
|
if (ntohl(msg[0]) != MAGIC_EET_DATA_PACKET)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
packet_size = ntohl(msg->size);
|
packet_size = ntohl(msg[1]);
|
||||||
/* Message should always be under 64K */
|
/* Message should always be under 64K */
|
||||||
if (packet_size > 64 * 1024)
|
if (packet_size > 64 * 1024)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
data = (void *)(msg + 1);
|
data = (void *)(msg + 2);
|
||||||
size -= sizeof (msg);
|
size -= sizeof (int) * 2;
|
||||||
if ((size_t)packet_size <= size)
|
if ((size_t)packet_size <= size)
|
||||||
{
|
{
|
||||||
/* Not a partial receive, go the quick way. */
|
/* Not a partial receive, go the quick way. */
|
||||||
|
@ -176,20 +169,20 @@ _eet_connection_raw_send(Eet_Connection *conn,
|
||||||
void *data,
|
void *data,
|
||||||
int data_size)
|
int data_size)
|
||||||
{
|
{
|
||||||
Eet_Message *message;
|
int *message;
|
||||||
|
|
||||||
/* Message should never be above 64K */
|
/* Message should never be above 64K */
|
||||||
if (data_size > 64 * 1024)
|
if (data_size > 64 * 1024)
|
||||||
return EINA_FALSE;
|
return EINA_FALSE;
|
||||||
|
|
||||||
message = alloca(data_size + sizeof (Eet_Message));
|
message = alloca(data_size + sizeof (int) * 2);
|
||||||
message->magic = htonl(MAGIC_EET_DATA_PACKET);
|
message[0] = htonl(MAGIC_EET_DATA_PACKET);
|
||||||
message->size = htonl(data_size);
|
message[1] = htonl(data_size);
|
||||||
|
|
||||||
memcpy(message + 1, data, data_size);
|
memcpy(message + 2, data, data_size);
|
||||||
|
|
||||||
conn->eet_write_cb(message,
|
conn->eet_write_cb(message,
|
||||||
data_size + sizeof (Eet_Message),
|
data_size + sizeof (int) * 2,
|
||||||
conn->user_data);
|
conn->user_data);
|
||||||
return EINA_TRUE;
|
return EINA_TRUE;
|
||||||
} /* _eet_connection_raw_send */
|
} /* _eet_connection_raw_send */
|
||||||
|
|
Loading…
Reference in New Issue