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
This commit is contained in:
Andrew Bettison 2013-12-18 17:42:45 +10:30
parent 3b5c0d2092
commit b5f7a088b2
2 changed files with 13 additions and 10 deletions

View File

@ -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) {

View File

@ -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.