aboutsummaryrefslogtreecommitdiff
path: root/src/util/container_meta_data.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2010-01-18 16:00:03 +0000
committerChristian Grothoff <christian@grothoff.org>2010-01-18 16:00:03 +0000
commitec4bcf7f589b285e5194394d1d72257ad25d4dd1 (patch)
tree8ba969f8c449b2f72cadaeb7c15e9121c2bde7e8 /src/util/container_meta_data.c
parent13d33fdf12293f614db6fa08026c321be2989c95 (diff)
downloadgnunet-ec4bcf7f589b285e5194394d1d72257ad25d4dd1.tar.gz
gnunet-ec4bcf7f589b285e5194394d1d72257ad25d4dd1.zip
misc fixes
Diffstat (limited to 'src/util/container_meta_data.c')
-rw-r--r--src/util/container_meta_data.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/util/container_meta_data.c b/src/util/container_meta_data.c
index 82847f7af..fadb0dede 100644
--- a/src/util/container_meta_data.c
+++ b/src/util/container_meta_data.c
@@ -519,7 +519,8 @@ GNUNET_CONTAINER_meta_data_get_thumbnail (const struct
519 } 519 }
520 pos = pos->next; 520 pos = pos->next;
521 } 521 }
522 if (match == NULL) 522 if ( (match == NULL) ||
523 (match->data_size == 0) )
523 return 0; 524 return 0;
524 *thumb = GNUNET_malloc (match->data_size); 525 *thumb = GNUNET_malloc (match->data_size);
525 memcpy (*thumb, match->data, match->data_size); 526 memcpy (*thumb, match->data, match->data_size);
@@ -855,9 +856,11 @@ GNUNET_CONTAINER_meta_data_serialize (const struct GNUNET_CONTAINER_MetaData
855 off -= pos->data_size; 856 off -= pos->data_size;
856 memcpy (&mdata[off], pos->data, pos->data_size); 857 memcpy (&mdata[off], pos->data, pos->data_size);
857 off -= plen; 858 off -= plen;
858 memcpy (&mdata[off], pos->plugin_name, plen); 859 if (pos->plugin_name != NULL)
860 memcpy (&mdata[off], pos->plugin_name, plen);
859 off -= mlen; 861 off -= mlen;
860 memcpy (&mdata[off], pos->mime_type, mlen); 862 if (pos->mime_type != NULL)
863 memcpy (&mdata[off], pos->mime_type, mlen);
861 i++; 864 i++;
862 pos = pos->next; 865 pos = pos->next;
863 } 866 }
@@ -866,6 +869,7 @@ GNUNET_CONTAINER_meta_data_serialize (const struct GNUNET_CONTAINER_MetaData
866 clen = 0; 869 clen = 0;
867 cdata = NULL; 870 cdata = NULL;
868 left = size; 871 left = size;
872 pos = md->items;
869 for (i=0;i<md->item_count;i++) 873 for (i=0;i<md->item_count;i++)
870 { 874 {
871 comp = GNUNET_NO; 875 comp = GNUNET_NO;
@@ -887,6 +891,7 @@ GNUNET_CONTAINER_meta_data_serialize (const struct GNUNET_CONTAINER_MetaData
887 hdr->entries = htonl (md->item_count); 891 hdr->entries = htonl (md->item_count);
888 if (GNUNET_YES == comp) 892 if (GNUNET_YES == comp)
889 { 893 {
894 GNUNET_assert (clen < left);
890 hdr->version = htonl (2 | HEADER_COMPRESSED); 895 hdr->version = htonl (2 | HEADER_COMPRESSED);
891 memcpy (&hdr[1], 896 memcpy (&hdr[1],
892 cdata, 897 cdata,
@@ -960,7 +965,8 @@ GNUNET_CONTAINER_meta_data_serialize (const struct GNUNET_CONTAINER_MetaData
960 if (pos->plugin_name != NULL) 965 if (pos->plugin_name != NULL)
961 left -= strlen (pos->plugin_name) + 1; 966 left -= strlen (pos->plugin_name) + 1;
962 if (pos->mime_type != NULL) 967 if (pos->mime_type != NULL)
963 left -= strlen (pos->mime_type) + 1; 968 left -= strlen (pos->mime_type) + 1;
969 pos = pos->next;
964 } 970 }
965 GNUNET_free (ent); 971 GNUNET_free (ent);
966 972