diff options
author | Christian Grothoff <christian@grothoff.org> | 2017-01-24 21:57:40 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2017-01-24 21:59:28 +0100 |
commit | 596a7b4d539dfb4080320e4d6c152d07d53fb66a (patch) | |
tree | fd2a742c661382d5c8ca04e3d128cd446a5cafbc /src/cadet/gnunet-service-cadet-new_channel.c | |
parent | 5db97de36b8dedb6c74b3297332b1ecd1276a877 (diff) | |
download | gnunet-596a7b4d539dfb4080320e4d6c152d07d53fb66a.tar.gz gnunet-596a7b4d539dfb4080320e4d6c152d07d53fb66a.zip |
fix bug from compiler inserting padding if we try to allocate data at the end of the struct instead of in a new area
Diffstat (limited to 'src/cadet/gnunet-service-cadet-new_channel.c')
-rw-r--r-- | src/cadet/gnunet-service-cadet-new_channel.c | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/src/cadet/gnunet-service-cadet-new_channel.c b/src/cadet/gnunet-service-cadet-new_channel.c index 98cfa8383..b97b2b577 100644 --- a/src/cadet/gnunet-service-cadet-new_channel.c +++ b/src/cadet/gnunet-service-cadet-new_channel.c | |||
@@ -126,9 +126,8 @@ struct CadetReliableMessage | |||
126 | /** | 126 | /** |
127 | * Data message we are trying to send. | 127 | * Data message we are trying to send. |
128 | */ | 128 | */ |
129 | struct GNUNET_CADET_ChannelAppDataMessage data_message; | 129 | struct GNUNET_CADET_ChannelAppDataMessage *data_message; |
130 | 130 | ||
131 | /* followed by variable-size payload */ | ||
132 | }; | 131 | }; |
133 | 132 | ||
134 | 133 | ||
@@ -420,6 +419,7 @@ channel_destroy (struct CadetChannel *ch) | |||
420 | GNUNET_CONTAINER_DLL_remove (ch->head_sent, | 419 | GNUNET_CONTAINER_DLL_remove (ch->head_sent, |
421 | ch->tail_sent, | 420 | ch->tail_sent, |
422 | crm); | 421 | crm); |
422 | GNUNET_free (crm->data_message); | ||
423 | GNUNET_free (crm); | 423 | GNUNET_free (crm); |
424 | } | 424 | } |
425 | if (NULL != ch->owner) | 425 | if (NULL != ch->owner) |
@@ -1188,7 +1188,7 @@ GCCH_handle_channel_plaintext_data_ack (struct CadetChannel *ch, | |||
1188 | for (crm = ch->head_sent; | 1188 | for (crm = ch->head_sent; |
1189 | NULL != crm; | 1189 | NULL != crm; |
1190 | crm = crm->next) | 1190 | crm = crm->next) |
1191 | if (ack->mid.mid == crm->data_message.mid.mid) | 1191 | if (ack->mid.mid == crm->data_message->mid.mid) |
1192 | break; | 1192 | break; |
1193 | if (NULL == crm) | 1193 | if (NULL == crm) |
1194 | { | 1194 | { |
@@ -1206,12 +1206,13 @@ GCCH_handle_channel_plaintext_data_ack (struct CadetChannel *ch, | |||
1206 | GNUNET_CONTAINER_DLL_remove (ch->head_sent, | 1206 | GNUNET_CONTAINER_DLL_remove (ch->head_sent, |
1207 | ch->tail_sent, | 1207 | ch->tail_sent, |
1208 | crm); | 1208 | crm); |
1209 | GNUNET_free (crm->data_message); | ||
1210 | GNUNET_free (crm); | ||
1209 | ch->pending_messages--; | 1211 | ch->pending_messages--; |
1210 | send_ack_to_client (ch, | 1212 | send_ack_to_client (ch, |
1211 | (NULL == ch->owner) | 1213 | (NULL == ch->owner) |
1212 | ? GNUNET_NO | 1214 | ? GNUNET_NO |
1213 | : GNUNET_YES); | 1215 | : GNUNET_YES); |
1214 | GNUNET_free (crm); | ||
1215 | GNUNET_assert (ch->pending_messages < ch->max_pending_messages); | 1216 | GNUNET_assert (ch->pending_messages < ch->max_pending_messages); |
1216 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1217 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1217 | "Received DATA_ACK on %s for message %u (%u ACKs pending)\n", | 1218 | "Received DATA_ACK on %s for message %u (%u ACKs pending)\n", |
@@ -1290,7 +1291,7 @@ retry_transmission (void *cls) | |||
1290 | ch->retry_data_task = NULL; | 1291 | ch->retry_data_task = NULL; |
1291 | GNUNET_assert (NULL == crm->qe); | 1292 | GNUNET_assert (NULL == crm->qe); |
1292 | crm->qe = GCT_send (ch->t, | 1293 | crm->qe = GCT_send (ch->t, |
1293 | &crm->data_message.header, | 1294 | &crm->data_message->header, |
1294 | &data_sent_cb, | 1295 | &data_sent_cb, |
1295 | crm); | 1296 | crm); |
1296 | } | 1297 | } |
@@ -1432,14 +1433,16 @@ GCCH_handle_local_data (struct CadetChannel *ch, | |||
1432 | } | 1433 | } |
1433 | 1434 | ||
1434 | /* Everything is correct, send the message. */ | 1435 | /* Everything is correct, send the message. */ |
1435 | crm = GNUNET_malloc (sizeof (*crm) + buf_len); | 1436 | crm = GNUNET_malloc (sizeof (*crm)); |
1436 | crm->ch = ch; | 1437 | crm->ch = ch; |
1437 | crm->data_message.header.size = htons (sizeof (struct GNUNET_CADET_ChannelAppDataMessage) + buf_len); | 1438 | crm->data_message = GNUNET_malloc (sizeof (struct GNUNET_CADET_ChannelAppDataMessage) |
1438 | crm->data_message.header.type = htons (GNUNET_MESSAGE_TYPE_CADET_CHANNEL_APP_DATA); | 1439 | + buf_len); |
1440 | crm->data_message->header.size = htons (sizeof (struct GNUNET_CADET_ChannelAppDataMessage) + buf_len); | ||
1441 | crm->data_message->header.type = htons (GNUNET_MESSAGE_TYPE_CADET_CHANNEL_APP_DATA); | ||
1439 | ch->mid_send.mid = htonl (ntohl (ch->mid_send.mid) + 1); | 1442 | ch->mid_send.mid = htonl (ntohl (ch->mid_send.mid) + 1); |
1440 | crm->data_message.mid = ch->mid_send; | 1443 | crm->data_message->mid = ch->mid_send; |
1441 | crm->data_message.ctn = ch->ctn; | 1444 | crm->data_message->ctn = ch->ctn; |
1442 | GNUNET_memcpy (&crm[1], | 1445 | GNUNET_memcpy (&crm->data_message[1], |
1443 | buf, | 1446 | buf, |
1444 | buf_len); | 1447 | buf_len); |
1445 | GNUNET_CONTAINER_DLL_insert (ch->head_sent, | 1448 | GNUNET_CONTAINER_DLL_insert (ch->head_sent, |
@@ -1450,7 +1453,7 @@ GCCH_handle_local_data (struct CadetChannel *ch, | |||
1450 | buf_len, | 1453 | buf_len, |
1451 | GCCH_2s (ch)); | 1454 | GCCH_2s (ch)); |
1452 | crm->qe = GCT_send (ch->t, | 1455 | crm->qe = GCT_send (ch->t, |
1453 | &crm->data_message.header, | 1456 | &crm->data_message->header, |
1454 | &data_sent_cb, | 1457 | &data_sent_cb, |
1455 | crm); | 1458 | crm); |
1456 | return GNUNET_OK; | 1459 | return GNUNET_OK; |