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
This commit is contained in:
parent
4c18532bd0
commit
d24f17df96
@ -505,17 +505,13 @@ quoted_print(int pflags, char *name, char *value)
|
|||||||
{
|
{
|
||||||
int qc;
|
int qc;
|
||||||
char *p = value;
|
char *p = value;
|
||||||
char *param_name_value;
|
|
||||||
|
|
||||||
/* An empty string needs quoting. */
|
/* An empty string needs quoting. */
|
||||||
if (!*p) {
|
if (!*p) {
|
||||||
asprintf(¶m_name_value, "{k:%s}{d:%s/\"\"}", name, name);
|
xo_emit("{ea:/%s}{da:/\"\"}", name, value, name);
|
||||||
xo_emit(param_name_value);
|
|
||||||
free(param_name_value);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
asprintf(¶m_name_value, "{:%s/%%s}", name);
|
|
||||||
/*
|
/*
|
||||||
* The value will be surrounded by quotes if it contains spaces
|
* The value will be surrounded by quotes if it contains spaces
|
||||||
* or quotes.
|
* or quotes.
|
||||||
@ -528,9 +524,7 @@ quoted_print(int pflags, char *name, char *value)
|
|||||||
if (qc && pflags & PRINT_QUOTED)
|
if (qc && pflags & PRINT_QUOTED)
|
||||||
xo_emit("{P:/%c}", qc);
|
xo_emit("{P:/%c}", qc);
|
||||||
|
|
||||||
xo_emit(param_name_value, value);
|
xo_emit("{a:/%s}", name, value);
|
||||||
|
|
||||||
free(param_name_value);
|
|
||||||
|
|
||||||
if (qc && pflags & PRINT_QUOTED)
|
if (qc && pflags & PRINT_QUOTED)
|
||||||
xo_emit("{P:/%c}", qc);
|
xo_emit("{P:/%c}", qc);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user