mirror of
https://git.hardenedbsd.org/hardenedbsd/HardenedBSD.git
synced 2024-11-15 14:56:13 +01:00
libjail: Handle an error from reallocarray() when trimming the buffer.
There is no API guarantee that realloc() will not fail when the buffer is shrinking. Handle it by simply returning the untrimmed buffer. While this is unlikely to ever happen in practice, it seems worth handling just to silence static analyzer warnings. PR: 243106 Submitted by: Hans Christian Woithe <chwoithe@yahoo.com> MFC after: 1 week
This commit is contained in:
parent
e9edde4110
commit
accd6aa25e
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=356476
@ -262,7 +262,10 @@ jailparam_all(struct jailparam **jpp)
|
|||||||
goto error;
|
goto error;
|
||||||
mib1[1] = 2;
|
mib1[1] = 2;
|
||||||
}
|
}
|
||||||
jp = reallocarray(jp, njp, sizeof(*jp));
|
/* Just return the untrimmed buffer if reallocarray() somehow fails. */
|
||||||
|
tjp = reallocarray(jp, njp, sizeof(*jp));
|
||||||
|
if (tjp != NULL)
|
||||||
|
jp = tjp;
|
||||||
*jpp = jp;
|
*jpp = jp;
|
||||||
return (njp);
|
return (njp);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user