View Issue Details

IDProjectCategoryView StatusLast Update
0001685GNUnetpublic2011-06-10 09:09
ReporterChristian Grothoff Assigned Tovminko Due Date
PrioritynormalSeverityminorReproducibilityhave not tried
Status closedResolutionfixed 
Summary0001685: uninitialized message fields somewhere in chat code
DescriptionWhen running

$ valgrind --trace-children=yes .libs/lt-test_chat_private_p2p

against SVN 15431, I get a warning about uninitialized bytes being passed to 'send'. This typically happens if some members of some message struct (often unused ones) are not initialized by the code prior to transmission.
Additional Information==8882== Syscall param socketcall.send(msg) points to uninitialised byte(s)
==8882== at 0x4169F61: send (socket.S:64)
==8882== by 0x4046051: transmit_ready (connection.c:1561)
==8882== by 0x405E50F: run_ready (scheduler.c:643)
==8882== by 0x405EAF0: GNUNET_SCHEDULER_run (scheduler.c:790)
==8882== by 0x405AF18: GNUNET_PROGRAM_run (program.c:227)
==8882== by 0x8049ED3: main (test_chat_private.c:675)
==8882== Address 0x4588de4 is 12 bytes inside a block of size 342 alloc'd
==8882== at 0x402695A: realloc (vg_replace_malloc.c:525)
==8882== by 0x403FA8D: GNUNET_xrealloc_ (common_allocation.c:167)
==8882== by 0x4045EFD: transmit_ready (connection.c:1546)
==8882== by 0x405E50F: run_ready (scheduler.c:643)
==8882== by 0x405EAF0: GNUNET_SCHEDULER_run (scheduler.c:790)
==8882== by 0x405AF18: GNUNET_PROGRAM_run (program.c:227)
==8882== by 0x8049ED3: main (test_chat_private.c:675)
TagsNo tags attached.
Attached Files
gnunet-bug1685-fix.patch (2,947 bytes)   
Index: chat.c
===================================================================
--- chat.c	(revision 15446)
+++ chat.c	(working copy)
@@ -187,8 +187,9 @@
   receipt->header.size = htons (msg_size);
   receipt->header.type =
     htons (GNUNET_MESSAGE_TYPE_CHAT_CONFIRMATION_RECEIPT);
+  receipt->reserved = htonl (0);
   receipt->sequence_number = src->received_msg->sequence_number;
-  receipt->reserved2 = 0;
+  receipt->reserved2 = htonl (0);
   receipt->timestamp = GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_get ());
   GNUNET_CRYPTO_rsa_key_get_public (src->chat_room->my_private_key, &pub_key);
   GNUNET_CRYPTO_hash (&pub_key,
@@ -565,6 +566,7 @@
   join_msg->msg_options = htonl (chat_room->msg_options);
   join_msg->room_name_len = htons (room_len);
   join_msg->reserved = htons (0);
+  join_msg->reserved2 = htonl (0);
   GNUNET_CRYPTO_rsa_key_get_public (chat_room->my_private_key, &join_msg->public_key);
   room = (char *) &join_msg[1];
   memcpy (room, chat_room->room_name, room_len);
Index: gnunet-service-chat.c
===================================================================
--- gnunet-service-chat.c	(revision 15446)
+++ gnunet-service-chat.c	(working copy)
@@ -474,7 +474,7 @@
   p2p_rnmsg->msg_options = trmsg->msg_options;
   p2p_rnmsg->sequence_number = trmsg->sequence_number;
   p2p_rnmsg->timestamp = trmsg->timestamp;
-  p2p_rnmsg->reserved = 0;
+  p2p_rnmsg->reserved = htons (0);
   p2p_rnmsg->sender = rnmsg->sender;
   p2p_rnmsg->target = trmsg->target;
   if (is_anon)
@@ -523,6 +523,7 @@
   m->msg_options = htonl (entry->msg_options);
   m->room_name_len = htons (room_len);
   m->reserved = htons (0);
+  m->reserved2 = htonl (0);
   m->public_key = entry->public_key;
   roomptr = (char *) &m[1];
   memcpy (roomptr, entry->room, room_len);
@@ -826,6 +827,7 @@
       p2p_crmsg = GNUNET_malloc (sizeof (struct P2PConfirmationReceiptMessage));
       p2p_crmsg->header.size = htons (sizeof (struct P2PConfirmationReceiptMessage));
       p2p_crmsg->header.type = htons (GNUNET_MESSAGE_TYPE_CHAT_P2P_CONFIRMATION_RECEIPT);
+      p2p_crmsg->reserved = htonl (0);
       p2p_crmsg->signature = receipt->signature;
       p2p_crmsg->purpose = receipt->purpose;
       p2p_crmsg->msg_sequence_number = receipt->sequence_number;
@@ -909,7 +911,7 @@
   m = buf;
   m->header.type = htons (GNUNET_MESSAGE_TYPE_CHAT_P2P_LEAVE_NOTIFICATION);
   m->header.size = htons (msg_size);
-  m->reserved = htons (0);
+  m->reserved = htonl (0);
   m->user = *public_key;
   GNUNET_free (public_key);
   return msg_size;
@@ -1336,6 +1338,7 @@
   rnmsg->header.type = htons (GNUNET_MESSAGE_TYPE_CHAT_MESSAGE_NOTIFICATION);
   rnmsg->msg_options = p2p_rnmsg->msg_options;
   rnmsg->sequence_number = p2p_rnmsg->sequence_number;
+  rnmsg->reserved = htonl (0);
   rnmsg->timestamp = p2p_rnmsg->timestamp;
   is_priv = (0 != memcmp (&all_zeros,
                            &p2p_rnmsg->target, sizeof (GNUNET_HashCode)));
gnunet-bug1685-fix.patch (2,947 bytes)   

Activities

vminko

2011-06-07 14:15

reporter   ~0004345

Proposed fix is attached.

Christian Grothoff

2011-06-10 09:06

manager   ~0004350

Fixed as proposed in SVN 15508.

Issue History

Date ModifiedUsernameFieldChange
2011-06-05 16:49Christian GrothoffNew Issue
2011-06-05 16:50Christian GrothoffAssigned To => vminko
2011-06-05 16:50Christian GrothoffStatusnew => assigned
2011-06-05 16:50Christian GrothoffCategoryother => chat service
2011-06-07 14:15vminkoFile Added: gnunet-bug1685-fix.patch
2011-06-07 14:15vminkoNote Added: 0004345
2011-06-10 09:06Christian GrothoffNote Added: 0004350
2011-06-10 09:06Christian GrothoffStatusassigned => resolved
2011-06-10 09:06Christian GrothoffResolutionopen => fixed
2011-06-10 09:09Christian GrothoffStatusresolved => closed
2013-08-31 19:34Christian GrothoffCategorychat service => (No Category)