From 0f3caa49abab25613b9adb60427929882a17eabc Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Fri, 8 Jul 2016 16:48:10 +0000 Subject: [PATCH] -fix shifting issues --- src/datacache/plugin_datacache_heap.c | 3 ++- src/fragmentation/defragmentation.c | 8 ++++---- src/statistics/statistics.h | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/datacache/plugin_datacache_heap.c b/src/datacache/plugin_datacache_heap.c index a32835cf4..afc320b20 100644 --- a/src/datacache/plugin_datacache_heap.c +++ b/src/datacache/plugin_datacache_heap.c @@ -245,7 +245,8 @@ heap_plugin_put (void *cls, GNUNET_array_grow (val->path_info, val->path_info_len, path_info_len); - memcpy (val->path_info, path_info, + memcpy (val->path_info, + path_info, path_info_len * sizeof (struct GNUNET_PeerIdentity)); (void) GNUNET_CONTAINER_multihashmap_put (plugin->map, &val->key, diff --git a/src/fragmentation/defragmentation.c b/src/fragmentation/defragmentation.c index 5433ffb5a..50fc4a1d5 100644 --- a/src/fragmentation/defragmentation.c +++ b/src/fragmentation/defragmentation.c @@ -506,7 +506,7 @@ GNUNET_DEFRAGMENT_process_fragment (struct GNUNET_DEFRAGMENT_Context *dc, if (n == 64) mc->bits = UINT64_MAX; /* set all 64 bit */ else - mc->bits = (1LL << n) - 1; /* set lowest 'bits' bit */ + mc->bits = (1LLU << n) - 1; /* set lowest 'bits' bit */ if (dc->list_size >= dc->num_msgs) discard_oldest_mc (dc); GNUNET_CONTAINER_DLL_insert (dc->head, @@ -516,9 +516,9 @@ GNUNET_DEFRAGMENT_process_fragment (struct GNUNET_DEFRAGMENT_Context *dc, } /* copy data to 'mc' */ - if (0 != (mc->bits & (1LL << bit))) + if (0 != (mc->bits & (1LLU << bit))) { - mc->bits -= 1LL << bit; + mc->bits -= 1LLU << bit; mbuf = (char *) &mc[1]; memcpy (&mbuf[bit * (dc->mtu - sizeof (struct FragmentHeader))], &fh[1], ntohs (msg->size) - sizeof (struct FragmentHeader)); @@ -543,7 +543,7 @@ GNUNET_DEFRAGMENT_process_fragment (struct GNUNET_DEFRAGMENT_Context *dc, /* count number of missing fragments after the current one */ bc = 0; for (b = bit; b < 64; b++) - if (0 != (mc->bits & (1LL << b))) + if (0 != (mc->bits & (1LLU << b))) bc++; else bc = 0; diff --git a/src/statistics/statistics.h b/src/statistics/statistics.h index ac88aadef..41863a64f 100644 --- a/src/statistics/statistics.h +++ b/src/statistics/statistics.h @@ -63,7 +63,7 @@ struct GNUNET_STATISTICS_ReplyMessage * Flag for the `struct GNUNET_STATISTICS_ReplyMessage` UID only. * Note that other messages use #GNUNET_STATISTICS_SETFLAG_PERSISTENT. */ -#define GNUNET_STATISTICS_PERSIST_BIT (1<<31) +#define GNUNET_STATISTICS_PERSIST_BIT ((uint32_t) (1LLU<<31)) /** * The value being set is an absolute change. -- 2.25.1