Date: Sat, 2 Jan 2021 05:27:39 GMT From: Kyle Evans <kevans@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Subject: git: 1e6afe0f7d23 - stable/12 - Fix bad libbxo format strings in jls Message-ID: <202101020527.1025RdQ7035512@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch stable/12 has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=1e6afe0f7d2346ac5b864b6b01bb9458f5349347 commit 1e6afe0f7d2346ac5b864b6b01bb9458f5349347 Author: Alex Richardson <arichardson@FreeBSD.org> AuthorDate: 2020-11-04 14:31:52 +0000 Commit: Kyle Evans <kevans@FreeBSD.org> CommitDate: 2021-01-02 05:27:10 +0000 Fix bad libbxo format strings in jls The existing format string for the empty case was trying to read varargs values that weren't passed to xo_emit. This appears to work on x86 (since the next argument is probably a pointer an empty string), but for CHERI we can bound variadic arguments and detect a read past the end. While touching these lines also use the libxo 'a' modifier to avoid having to construct the libxo format string using asprintf. Found by: CHERI Reviewed By: allanjude Differential Revision: https://reviews.freebsd.org/D26885 (cherry picked from commit d24f17df969107b47af60e5ccc1ed0f1a467fc6f) --- usr.sbin/jls/jls.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/usr.sbin/jls/jls.c b/usr.sbin/jls/jls.c index 46c5a5c8b15e..374ee14bf080 100644 --- a/usr.sbin/jls/jls.c +++ b/usr.sbin/jls/jls.c @@ -505,17 +505,13 @@ quoted_print(int pflags, char *name, char *value) { int qc; char *p = value; - char *param_name_value; /* An empty string needs quoting. */ if (!*p) { - asprintf(¶m_name_value, "{k:%s}{d:%s/\"\"}", name, name); - xo_emit(param_name_value); - free(param_name_value); + xo_emit("{ea:/%s}{da:/\"\"}", name, value, name); return; } - asprintf(¶m_name_value, "{:%s/%%s}", name); /* * The value will be surrounded by quotes if it contains spaces * or quotes. @@ -528,9 +524,7 @@ quoted_print(int pflags, char *name, char *value) if (qc && pflags & PRINT_QUOTED) xo_emit("{P:/%c}", qc); - xo_emit(param_name_value, value); - - free(param_name_value); + xo_emit("{a:/%s}", name, value); if (qc && pflags & PRINT_QUOTED) xo_emit("{P:/%c}", qc);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202101020527.1025RdQ7035512>