Skip to content

Commit 80fdd8b

Browse files
committed
librlist: fix uninitialized error text in rlist_alloc()
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.
1 parent f13739d commit 80fdd8b

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/common/librlist/rlist.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2164,6 +2164,7 @@ struct rlist *rlist_alloc (struct rlist *rl,
21642164

21652165
if (!rl || !ai) {
21662166
errno = EINVAL;
2167+
errprintf (errp, "Invalid argument");
21672168
return NULL;
21682169
}
21692170

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

21782181
if (!result && (errno == ENOSPC)) {
21792182
if (!rlist_alloc_feasible (rl,

0 commit comments

Comments
 (0)