Skip to content

Commit

Permalink
librlist: fix uninitialized error tex in rlist_alloc()
Browse files Browse the repository at this point in the history
Problem: In some cases, rlist_alloc() leaves errp->text uninitialized
when returning an error. This can lead the caller to access unitialized
bytes, potentially causing a crash.

Always use errprintf() before returning an error from this function.
  • Loading branch information
grondo committed Apr 8, 2024
1 parent 86a8956 commit 3257644
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/common/librlist/rlist.c
Original file line number Diff line number Diff line change
Expand Up @@ -2164,6 +2164,7 @@ struct rlist *rlist_alloc (struct rlist *rl,

if (!rl || !ai) {
errno = EINVAL;
errprintf (errp, "Invalid argument");
return NULL;
}

Expand All @@ -2174,6 +2175,8 @@ struct rlist *rlist_alloc (struct rlist *rl,
result = rlist_alloc_constrained (rl, ai, errp);
else {
result = rlist_try_alloc (rl, ai);
if (!result)
errprintf (errp, "%s", strerror (errno));

if (!result && (errno == ENOSPC)) {
if (!rlist_alloc_feasible (rl,
Expand Down

0 comments on commit 3257644

Please sign in to comment.