Author: nevans Date: 2008-02-27 16:08:12 -0700 (Wed, 27 Feb 2008) New Revision: 6479
Modified: GNUnet/src/applications/chat/chat.c GNUnet/src/applications/chat/clientapi.c Log: that's better Modified: GNUnet/src/applications/chat/chat.c =================================================================== --- GNUnet/src/applications/chat/chat.c 2008-02-27 22:29:18 UTC (rev 6478) +++ GNUnet/src/applications/chat/chat.c 2008-02-27 23:08:12 UTC (rev 6479) @@ -71,7 +71,7 @@ unsigned long room_name_len; cmsg = (CS_chat_MESSAGE *) message; - if (ntohs (cmsg->header.size) < (sizeof (CS_chat_MESSAGE)+sizeof (GNUNET_MessageHeader))) + if (ntohs (cmsg->header.size) < sizeof (CS_chat_MESSAGE)) { GNUNET_GE_BREAK (NULL, 0); return GNUNET_SYSERR; /* invalid message */ @@ -81,7 +81,7 @@ header_size = ntohs (cmsg->header.size); nick_len = ntohs (cmsg->nick_len); msg_len = ntohs (cmsg->msg_len); - room_name_len = header_size - sizeof (GNUNET_MessageHeader) - sizeof (CS_chat_MESSAGE) - nick_len - msg_len; + room_name_len = header_size - sizeof (CS_chat_MESSAGE) - nick_len - msg_len; if (header_size < (nick_len + msg_len + room_name_len)) { @@ -161,7 +161,7 @@ cmsg = (CS_chat_JOIN_MESSAGE *) message; - if (ntohs (cmsg->header.size) < (sizeof (CS_chat_JOIN_MESSAGE) + sizeof (GNUNET_MessageHeader))) + if (ntohs (cmsg->header.size) < sizeof (CS_chat_JOIN_MESSAGE)) { GNUNET_GE_BREAK (NULL, 0); return GNUNET_SYSERR; /* invalid message */ @@ -171,10 +171,10 @@ header_size = ntohs (cmsg->header.size); nick_len = ntohs (cmsg->nick_len); pubkey_len = ntohs (cmsg->pubkey_len); - room_name_len = 4 + header_size - sizeof (GNUNET_MessageHeader) - sizeof (CS_chat_JOIN_MESSAGE) - nick_len - pubkey_len; + room_name_len = header_size - sizeof (CS_chat_JOIN_MESSAGE) - nick_len - pubkey_len; - fprintf(stderr,"MessageHeader size : %d\nJOIN_MESSAGE size : %d\nheader_size : %d\nnick_len : %d\npubkey_len : %d\nroom_name_len : %d\n",sizeof (GNUNET_MessageHeader),sizeof (CS_chat_JOIN_MESSAGE),header_size,nick_len,pubkey_len,room_name_len); - fprintf(stderr,"According to my addition, header_size should be %d\n",nick_len+pubkey_len+room_name_len+sizeof (CS_chat_JOIN_MESSAGE) + sizeof (GNUNET_MessageHeader)); + fprintf(stderr,"JOIN_MESSAGE size : %d\nheader_size : %d\nnick_len : %d\npubkey_len : %d\nroom_name_len : %d\n",sizeof (CS_chat_JOIN_MESSAGE),header_size,nick_len,pubkey_len,room_name_len); + fprintf(stderr,"According to my addition, header_size should be %d\n",nick_len+pubkey_len+room_name_len+sizeof (CS_chat_JOIN_MESSAGE)); if (header_size < (nick_len + pubkey_len + room_name_len)) { GNUNET_GE_BREAK (NULL, 0); Modified: GNUnet/src/applications/chat/clientapi.c =================================================================== --- GNUnet/src/applications/chat/clientapi.c 2008-02-27 22:29:18 UTC (rev 6478) +++ GNUnet/src/applications/chat/clientapi.c 2008-02-27 23:08:12 UTC (rev 6479) @@ -82,7 +82,7 @@ } if ((reply->size < - ntohs (sizeof (GNUNET_MessageHeader) + sizeof (CS_chat_MESSAGE))) + ntohs (sizeof (CS_chat_MESSAGE))) || (reply->type != ntohs (GNUNET_CS_PROTO_CHAT_MSG))) { GNUNET_GE_BREAK (NULL, 0); @@ -98,7 +98,7 @@ nick_len = ntohs (received_msg->nick_len); msg_len = ntohs (received_msg->msg_len); /* NO NEED TO SEND ROOM! */ - room_name_len = size - nick_len - msg_len - sizeof(CS_chat_MESSAGE) - sizeof(GNUNET_MessageHeader); + room_name_len = size - nick_len - msg_len - sizeof(CS_chat_MESSAGE); if (size < (nick_len + msg_len + room_name_len)) { @@ -331,10 +331,8 @@ GNUNET_MessageHeader cs_msg_hdr; CS_chat_MESSAGE *msg_to_send; - - cs_msg_hdr.size = - htons (sizeof (GNUNET_MessageHeader) + sizeof (CS_chat_MESSAGE) + + htons (sizeof (CS_chat_MESSAGE) + strlen (room->nickname) + strlen (message) + strlen (room->room_name)); cs_msg_hdr.type = htons (GNUNET_CS_PROTO_CHAT_MSG); _______________________________________________ GNUnet-SVN mailing list GNUnet-SVN@gnu.org http://lists.gnu.org/mailman/listinfo/gnunet-svn