mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-03-21 23:16:50 +08:00
Merge tag 'bootconfig-fixes-v7.0-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace
Pull bootconfig fixes from Masami Hiramatsu: - fix off-by-one in xbc_verify_tree() unclosed brace error. This fixes a wrong error place in unclosed brace error message - check bounds before writing in __xbc_open_brace(). This fixes to check the array index before setting array, so that the bootconfig can support 16th-depth nested brace correctly - fix snprintf truncation check in xbc_node_compose_key_after(). This fixes to handle the return value of snprintf() correctly in case of the return value == size - Add bootconfig tests about braces Add test cases for checking error position about unclosed brace and ensuring supporting 16th depth nested braces correctly * tag 'bootconfig-fixes-v7.0-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace: bootconfig: Add bootconfig tests about braces lib/bootconfig: fix snprintf truncation check in xbc_node_compose_key_after() lib/bootconfig: check bounds before writing in __xbc_open_brace() lib/bootconfig: fix off-by-one in xbc_verify_tree() unclosed brace error
This commit is contained in:
@@ -316,7 +316,7 @@ int __init xbc_node_compose_key_after(struct xbc_node *root,
|
||||
depth ? "." : "");
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
if (ret > size) {
|
||||
if (ret >= size) {
|
||||
size = 0;
|
||||
} else {
|
||||
size -= ret;
|
||||
@@ -532,9 +532,9 @@ static char *skip_spaces_until_newline(char *p)
|
||||
static int __init __xbc_open_brace(char *p)
|
||||
{
|
||||
/* Push the last key as open brace */
|
||||
open_brace[brace_index++] = xbc_node_index(last_parent);
|
||||
if (brace_index >= XBC_DEPTH_MAX)
|
||||
return xbc_parse_error("Exceed max depth of braces", p);
|
||||
open_brace[brace_index++] = xbc_node_index(last_parent);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -802,7 +802,7 @@ static int __init xbc_verify_tree(void)
|
||||
|
||||
/* Brace closing */
|
||||
if (brace_index) {
|
||||
n = &xbc_nodes[open_brace[brace_index]];
|
||||
n = &xbc_nodes[open_brace[brace_index - 1]];
|
||||
return xbc_parse_error("Brace is not closed",
|
||||
xbc_node_get_data(n));
|
||||
}
|
||||
|
||||
4
tools/bootconfig/samples/bad-non-closed-brace.bconf
Normal file
4
tools/bootconfig/samples/bad-non-closed-brace.bconf
Normal file
@@ -0,0 +1,4 @@
|
||||
foo {
|
||||
bar {
|
||||
buz
|
||||
}
|
||||
19
tools/bootconfig/samples/bad-over-max-brace.bconf
Normal file
19
tools/bootconfig/samples/bad-over-max-brace.bconf
Normal file
@@ -0,0 +1,19 @@
|
||||
key1 {
|
||||
key2 {
|
||||
key3 {
|
||||
key4 {
|
||||
key5 {
|
||||
key6 {
|
||||
key7 {
|
||||
key8 {
|
||||
key9 {
|
||||
key10 {
|
||||
key11 {
|
||||
key12 {
|
||||
key13 {
|
||||
key14 {
|
||||
key15 {
|
||||
key16 {
|
||||
key17 {
|
||||
}}}}}}}}}}}}}}}}}
|
||||
|
||||
1
tools/bootconfig/samples/exp-good-nested-brace.bconf
Normal file
1
tools/bootconfig/samples/exp-good-nested-brace.bconf
Normal file
@@ -0,0 +1 @@
|
||||
key1.key2.key3.key4.key5.key6.key7.key8.key9.key10.key11.key12.key13.key14.key15.key16;
|
||||
18
tools/bootconfig/samples/good-nested-brace.bconf
Normal file
18
tools/bootconfig/samples/good-nested-brace.bconf
Normal file
@@ -0,0 +1,18 @@
|
||||
key1 {
|
||||
key2 {
|
||||
key3 {
|
||||
key4 {
|
||||
key5 {
|
||||
key6 {
|
||||
key7 {
|
||||
key8 {
|
||||
key9 {
|
||||
key10 {
|
||||
key11 {
|
||||
key12 {
|
||||
key13 {
|
||||
key14 {
|
||||
key15 {
|
||||
key16 {
|
||||
}}}}}}}}}}}}}}}}
|
||||
|
||||
@@ -171,6 +171,15 @@ $BOOTCONF $INITRD > $OUTFILE
|
||||
xfail grep -q 'val[[:space:]]' $OUTFILE
|
||||
xpass grep -q 'val2[[:space:]]' $OUTFILE
|
||||
|
||||
echo "Showing correct line:column of no closing brace"
|
||||
cat > $TEMPCONF << EOF
|
||||
foo {
|
||||
bar {
|
||||
}
|
||||
EOF
|
||||
$BOOTCONF -a $TEMPCONF $INITRD 2> $OUTFILE
|
||||
xpass grep -q "1:1" $OUTFILE
|
||||
|
||||
echo "=== expected failure cases ==="
|
||||
for i in samples/bad-* ; do
|
||||
xfail $BOOTCONF -a $i $INITRD
|
||||
|
||||
Reference in New Issue
Block a user