Date: Tue, 7 Jan 2020 21:44:27 +0000 (UTC) From: Mark Johnston <markj@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r356476 - head/lib/libjail Message-ID: <202001072144.007LiRb7063462@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: markj Date: Tue Jan 7 21:44:27 2020 New Revision: 356476 URL: https://svnweb.freebsd.org/changeset/base/356476 Log: 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 Modified: head/lib/libjail/jail.c Modified: head/lib/libjail/jail.c ============================================================================== --- head/lib/libjail/jail.c Tue Jan 7 21:29:42 2020 (r356475) +++ head/lib/libjail/jail.c Tue Jan 7 21:44:27 2020 (r356476) @@ -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);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202001072144.007LiRb7063462>