Skip to content

Commit f13739d

Browse files
committed
librlist: ignore missing ranks in rlist_mark_up/down
Problem: rlist_mark_state() doesn't check the return value from rlist_find_rank(). If a rank is passed to rlist_mark_up() or rlist_mark_down() that doesn't exist in the current rlist, then this will result in a dereference of NULL and a segfault. Skip ranks that don't exist in rlist_mark_start(), effectively ignoring invalid ranks passed to rlist_mark_up() and rlist_mark_down(). This is simpler than returning an error, which would require multiple iterations of the ranks idset as well as more complex error handling on the caller side.
1 parent 111d75b commit f13739d

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/common/librlist/rlist.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2313,9 +2313,11 @@ static int rlist_mark_state (struct rlist *rl, bool up, const char *ids)
23132313
i = idset_first (idset);
23142314
while (i != IDSET_INVALID_ID) {
23152315
struct rnode *n = rlist_find_rank (rl, i);
2316-
if (n->up != up)
2317-
count += idset_count (n->cores->avail);
2318-
n->up = up;
2316+
if (n) {
2317+
if (n->up != up)
2318+
count += idset_count (n->cores->avail);
2319+
n->up = up;
2320+
}
23192321
i = idset_next (idset, i);
23202322
}
23212323
idset_destroy (idset);

0 commit comments

Comments
 (0)