aboutsummaryrefslogtreecommitdiff
path: root/src/fs/fs_publish.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2010-04-04 22:04:00 +0000
committerChristian Grothoff <christian@grothoff.org>2010-04-04 22:04:00 +0000
commit0663125e0f41ee120736944ef153074f6251b957 (patch)
tree975543b6194c87b076547f63d8c344b87e21e75a /src/fs/fs_publish.c
parent4b78e6983509f2078c4f52888187436c0a7b6aeb (diff)
downloadgnunet-0663125e0f41ee120736944ef153074f6251b957.tar.gz
gnunet-0663125e0f41ee120736944ef153074f6251b957.zip
bugfixes, more tests
Diffstat (limited to 'src/fs/fs_publish.c')
-rw-r--r--src/fs/fs_publish.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/src/fs/fs_publish.c b/src/fs/fs_publish.c
index 18b064698..0931b6829 100644
--- a/src/fs/fs_publish.c
+++ b/src/fs/fs_publish.c
@@ -707,6 +707,7 @@ hash_for_index_cb (void *cls,
707 struct GNUNET_CLIENT_Connection *client; 707 struct GNUNET_CLIENT_Connection *client;
708 uint32_t dev; 708 uint32_t dev;
709 uint64_t ino; 709 uint64_t ino;
710 char *fn;
710 711
711 p = sc->fi_pos; 712 p = sc->fi_pos;
712 if (NULL == res) 713 if (NULL == res)
@@ -724,13 +725,15 @@ hash_for_index_cb (void *cls,
724 publish_content (sc); 725 publish_content (sc);
725 return; 726 return;
726 } 727 }
727 slen = strlen (p->data.file.filename) + 1; 728 fn = GNUNET_STRINGS_filename_expand (p->data.file.filename);
729 slen = strlen (fn) + 1;
728 if (slen > GNUNET_SERVER_MAX_MESSAGE_SIZE - sizeof(struct IndexStartMessage)) 730 if (slen > GNUNET_SERVER_MAX_MESSAGE_SIZE - sizeof(struct IndexStartMessage))
729 { 731 {
730 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 732 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
731 _("Can not index file `%s': %s. Will try to insert instead.\n"), 733 _("Can not index file `%s': %s. Will try to insert instead.\n"),
732 p->data.file.filename, 734 fn,
733 _("filename too long")); 735 _("filename too long"));
736 GNUNET_free (fn);
734 p->data.file.do_index = GNUNET_NO; 737 p->data.file.do_index = GNUNET_NO;
735 publish_content (sc); 738 publish_content (sc);
736 return; 739 return;
@@ -752,6 +755,7 @@ hash_for_index_cb (void *cls,
752 _("could not connect to `fs' service")); 755 _("could not connect to `fs' service"));
753 p->data.file.do_index = GNUNET_NO; 756 p->data.file.do_index = GNUNET_NO;
754 publish_content (sc); 757 publish_content (sc);
758 GNUNET_free (fn);
755 return; 759 return;
756 } 760 }
757 p->data.file.file_id = *res; 761 p->data.file.file_id = *res;
@@ -777,8 +781,9 @@ hash_for_index_cb (void *cls,
777 } 781 }
778 ism->file_id = *res; 782 ism->file_id = *res;
779 memcpy (&ism[1], 783 memcpy (&ism[1],
780 p->data.file.filename, 784 fn,
781 slen); 785 slen);
786 GNUNET_free (fn);
782 sc->client = client; 787 sc->client = client;
783 GNUNET_break (GNUNET_YES == 788 GNUNET_break (GNUNET_YES ==
784 GNUNET_CLIENT_transmit_and_get_response (client, 789 GNUNET_CLIENT_transmit_and_get_response (client,
@@ -1465,7 +1470,7 @@ GNUNET_FS_publish_sks (struct GNUNET_FS_Handle *h,
1465 struct GNUNET_FS_Namespace *namespace, 1470 struct GNUNET_FS_Namespace *namespace,
1466 const char *identifier, 1471 const char *identifier,
1467 const char *update, 1472 const char *update,
1468 struct GNUNET_CONTAINER_MetaData *meta, 1473 const struct GNUNET_CONTAINER_MetaData *meta,
1469 const struct GNUNET_FS_Uri *uri, 1474 const struct GNUNET_FS_Uri *uri,
1470 struct GNUNET_TIME_Absolute expirationTime, 1475 struct GNUNET_TIME_Absolute expirationTime,
1471 uint32_t anonymity, 1476 uint32_t anonymity,
@@ -1487,17 +1492,22 @@ GNUNET_FS_publish_sks (struct GNUNET_FS_Handle *h,
1487 struct SBlock *sb; 1492 struct SBlock *sb;
1488 struct SBlock *sb_enc; 1493 struct SBlock *sb_enc;
1489 char *dest; 1494 char *dest;
1495 struct GNUNET_CONTAINER_MetaData *mmeta;
1490 GNUNET_HashCode key; /* hash of thisId = key */ 1496 GNUNET_HashCode key; /* hash of thisId = key */
1491 GNUNET_HashCode id; /* hash of hc = identifier */ 1497 GNUNET_HashCode id; /* hash of hc = identifier */
1492 GNUNET_HashCode query; /* id ^ nsid = DB query */ 1498 GNUNET_HashCode query; /* id ^ nsid = DB query */
1493 1499
1500 if (NULL == meta)
1501 mmeta = GNUNET_CONTAINER_meta_data_create ();
1502 else
1503 mmeta = GNUNET_CONTAINER_meta_data_duplicate (meta);
1494 uris = GNUNET_FS_uri_to_string (uri); 1504 uris = GNUNET_FS_uri_to_string (uri);
1495 slen = strlen (uris) + 1; 1505 slen = strlen (uris) + 1;
1496 idlen = strlen (identifier); 1506 idlen = strlen (identifier);
1497 if (update == NULL) 1507 if (update == NULL)
1498 update = ""; 1508 update = "";
1499 nidlen = strlen (update) + 1; 1509 nidlen = strlen (update) + 1;
1500 mdsize = GNUNET_CONTAINER_meta_data_get_serialized_size (meta); 1510 mdsize = GNUNET_CONTAINER_meta_data_get_serialized_size (mmeta);
1501 size = sizeof (struct SBlock) + slen + nidlen + mdsize; 1511 size = sizeof (struct SBlock) + slen + nidlen + mdsize;
1502 if (size > MAX_SBLOCK_SIZE) 1512 if (size > MAX_SBLOCK_SIZE)
1503 { 1513 {
@@ -1510,10 +1520,11 @@ GNUNET_FS_publish_sks (struct GNUNET_FS_Handle *h,
1510 dest += nidlen; 1520 dest += nidlen;
1511 memcpy (dest, uris, slen); 1521 memcpy (dest, uris, slen);
1512 dest += slen; 1522 dest += slen;
1513 mdsize = GNUNET_CONTAINER_meta_data_serialize (meta, 1523 mdsize = GNUNET_CONTAINER_meta_data_serialize (mmeta,
1514 &dest, 1524 &dest,
1515 mdsize, 1525 mdsize,
1516 GNUNET_CONTAINER_META_DATA_SERIALIZE_PART); 1526 GNUNET_CONTAINER_META_DATA_SERIALIZE_PART);
1527 GNUNET_CONTAINER_meta_data_destroy (mmeta);
1517 if (mdsize == -1) 1528 if (mdsize == -1)
1518 { 1529 {
1519 GNUNET_break (0); 1530 GNUNET_break (0);