From b5f7a088b27d4c9cf93d50ca9dbfd78f8fd536d5 Mon Sep 17 00:00:00 2001 From: Andrew Bettison Date: Wed, 18 Dec 2013 17:42:45 +1030 Subject: [PATCH] Fix rhizome_fill_manifest() 'name' semantics Only set 'name' field if the given pathname is valid Do not set 'name' field if no pathname supplied --- meshms.c | 1 + rhizome_bundle.c | 22 ++++++++++++---------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/meshms.c b/meshms.c index 192504c8..928b6699 100644 --- a/meshms.c +++ b/meshms.c @@ -108,6 +108,7 @@ static int get_my_conversation_bundle(const sid_t *my_sidp, rhizome_manifest *m) assert(m->haveSecret); if (m->haveSecret == NEW_BUNDLE_ID) { rhizome_manifest_set_service(m, RHIZOME_SERVICE_FILE); + rhizome_manifest_set_name(m, ""); if (rhizome_fill_manifest(m, NULL, my_sidp) == -1) return WHY("Invalid manifest"); if (config.debug.meshms) { diff --git a/rhizome_bundle.c b/rhizome_bundle.c index 304cdaf6..86906828 100644 --- a/rhizome_bundle.c +++ b/rhizome_bundle.c @@ -1144,18 +1144,20 @@ int rhizome_fill_manifest(rhizome_manifest *m, const char *filepath, const sid_t } if (strcasecmp(RHIZOME_SERVICE_FILE, m->service) == 0) { - if (m->name == NULL) { - if (filepath && *filepath) { - const char *name = strrchr(filepath, '/'); - rhizome_manifest_set_name(m, name ? name + 1 : filepath); - } else - rhizome_manifest_set_name(m, ""); + if (m->name) { if (config.debug.rhizome) - DEBUGF("missing 'name', set default name=%s", alloca_str_toprint(m->name)); - } else { - if (config.debug.rhizome) - DEBUGF("manifest contains name=%s", alloca_str_toprint(m->name)); + DEBUGF("manifest already contains name=%s", alloca_str_toprint(m->name)); + } else if (filepath) { + const char *name = strrchr(filepath, '/'); + if (!name) + name = filepath; + if (rhizome_str_is_manifest_name(name)) + rhizome_manifest_set_name(m, name); + else if (config.debug.rhizome) + DEBUGF("invalid rhizome name %s -- not used", alloca_str_toprint(name)); } + else if (config.debug.rhizome) + DEBUGF("manifest missing 'name'"); } // Anything sent from one person to another should be considered private and encrypted by default.