aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/transport/gnunet-communicator-unix.c66
1 files changed, 29 insertions, 37 deletions
diff --git a/src/transport/gnunet-communicator-unix.c b/src/transport/gnunet-communicator-unix.c
index 5d7949b97..7d7f18a9c 100644
--- a/src/transport/gnunet-communicator-unix.c
+++ b/src/transport/gnunet-communicator-unix.c
@@ -784,47 +784,39 @@ select_read_cb (void *cls)
784 } 784 }
785 785
786 { 786 {
787 uint16_t offset = 0;
788 uint16_t tsize = msize - sizeof(struct UNIXMessage); 787 uint16_t tsize = msize - sizeof(struct UNIXMessage);
789 const char *msgbuf = (const char *) &msg[1];
790 788
791 while (offset + sizeof(struct GNUNET_MessageHeader) <= tsize) 789 const struct GNUNET_MessageHeader *currhdr;
790 struct GNUNET_MessageHeader al_hdr;
791
792 currhdr = (const struct GNUNET_MessageHeader *) &msg[1];
793 /* ensure aligned access */
794 memcpy (&al_hdr, currhdr, sizeof(al_hdr));
795 if ((tsize < sizeof(struct GNUNET_MessageHeader)) ||
796 (tsize != ntohs(al_hdr.size)))
792 { 797 {
793 const struct GNUNET_MessageHeader *currhdr; 798 GNUNET_break_op (0);
794 struct GNUNET_MessageHeader al_hdr; 799 return;
795 uint16_t csize; 800 }
796 801 ret = GNUNET_TRANSPORT_communicator_receive (ch,
797 currhdr = (const struct GNUNET_MessageHeader *) &msgbuf[offset]; 802 &msg->sender,
798 /* ensure aligned access */ 803 currhdr,
799 memcpy (&al_hdr, currhdr, sizeof(al_hdr)); 804 GNUNET_TIME_UNIT_FOREVER_REL,
800 csize = ntohs (al_hdr.size); 805 &receive_complete_cb,
801 if ((csize < sizeof(struct GNUNET_MessageHeader)) || 806 NULL);
802 (csize > tsize - offset)) 807 if (GNUNET_SYSERR == ret)
803 { 808 {
804 GNUNET_break_op (0); 809 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
805 break; 810 "Transport not up!\n");
806 } 811 return; /* transport not up */
807 ret = GNUNET_TRANSPORT_communicator_receive (ch, 812 }
808 &msg->sender, 813 if (GNUNET_NO == ret)
809 currhdr, 814 {
810 GNUNET_TIME_UNIT_FOREVER_REL, 815 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
811 &receive_complete_cb, 816 "Error sending message to transport\n");
812 NULL); 817 return;
813 if (GNUNET_SYSERR == ret)
814 {
815 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
816 "Transport not up!\n");
817 return; /* transport not up */
818 }
819 if (GNUNET_NO == ret)
820 {
821 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
822 "Error sending message to transport\n");
823 break;
824 }
825 delivering_messages++;
826 offset += csize;
827 } 818 }
819 delivering_messages++;
828 } 820 }
829 if (delivering_messages >= max_queue_length) 821 if (delivering_messages >= max_queue_length)
830 { 822 {