aboutsummaryrefslogtreecommitdiff
path: root/lib/libjail
diff options
context:
space:
mode:
authorMark Johnston <markj@FreeBSD.org>2020-01-07 21:44:27 +0000
committerMark Johnston <markj@FreeBSD.org>2020-01-07 21:44:27 +0000
commitaccd6aa25eb53de2f351ce0acf10a45a97723506 (patch)
tree41e8d9643377cfe76c2a8cec70d6bc2a4c701839 /lib/libjail
parente9edde4110d7a47d07695a83cd0d2d00e9a08d37 (diff)
downloadsrc-accd6aa25eb53de2f351ce0acf10a45a97723506.tar.gz
src-accd6aa25eb53de2f351ce0acf10a45a97723506.zip
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
Notes
Notes: svn path=/head/; revision=356476
Diffstat (limited to 'lib/libjail')
-rw-r--r--lib/libjail/jail.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/libjail/jail.c b/lib/libjail/jail.c
index 6a35cdc6dde5..3e0c2a0f98cb 100644
--- a/lib/libjail/jail.c
+++ b/lib/libjail/jail.c
@@ -262,7 +262,10 @@ jailparam_all(struct jailparam **jpp)
goto error;
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;
return (njp);