Skip to content

Commit

Permalink
Fix creation/rename of top-level profile sections
Browse files Browse the repository at this point in the history
profile_rename_section should demand only one name.

profile_add_relation should demand only one name if it is creating a
new section.  It aso needs to reset state before calling
profile_find_node for the section, in case it didn't look up any
parent sections previously.

(cherry picked from commit 590df2f)

ticket: 7972
version_fixed: 1.12.2
status: resolved
  • Loading branch information
greghudson authored and tlyu committed Aug 7, 2014
1 parent a3ae1ea commit eb0a3da
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/util/profile/prof_set.c
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ profile_rename_section(profile_t profile, const char **names,
if (retval)
return retval;

if (names == 0 || names[0] == 0 || names[1] == 0)
if (names == 0 || names[0] == 0)
return PROF_BAD_NAMESET;

k5_mutex_lock(&profile->first_file->data->lock);
Expand Down Expand Up @@ -264,7 +264,8 @@ profile_add_relation(profile_t profile, const char **names,
if (retval)
return retval;

if (names == 0 || names[0] == 0 || names[1] == 0)
/* Require at least two names for a new relation, one for a new section. */
if (names == 0 || names[0] == 0 || (names[1] == 0 && new_value))
return PROF_BAD_NAMESET;

k5_mutex_lock(&profile->first_file->data->lock);
Expand All @@ -282,6 +283,7 @@ profile_add_relation(profile_t profile, const char **names,
}

if (new_value == 0) {
state = 0;
retval = profile_find_node(section, *cpp, 0, 1, &state, 0);
if (retval == 0) {
k5_mutex_unlock(&profile->first_file->data->lock);
Expand Down

0 comments on commit eb0a3da

Please sign in to comment.