Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

+54 -3
+3 -3
lib/bootconfig.c
··· 316 316 depth ? "." : ""); 317 317 if (ret < 0) 318 318 return ret; 319 - if (ret > size) { 319 + if (ret >= size) { 320 320 size = 0; 321 321 } else { 322 322 size -= ret; ··· 532 532 static int __init __xbc_open_brace(char *p) 533 533 { 534 534 /* Push the last key as open brace */ 535 - open_brace[brace_index++] = xbc_node_index(last_parent); 536 535 if (brace_index >= XBC_DEPTH_MAX) 537 536 return xbc_parse_error("Exceed max depth of braces", p); 537 + open_brace[brace_index++] = xbc_node_index(last_parent); 538 538 539 539 return 0; 540 540 } ··· 802 802 803 803 /* Brace closing */ 804 804 if (brace_index) { 805 - n = &xbc_nodes[open_brace[brace_index]]; 805 + n = &xbc_nodes[open_brace[brace_index - 1]]; 806 806 return xbc_parse_error("Brace is not closed", 807 807 xbc_node_get_data(n)); 808 808 }
+4
tools/bootconfig/samples/bad-non-closed-brace.bconf
··· 1 + foo { 2 + bar { 3 + buz 4 + }
+19
tools/bootconfig/samples/bad-over-max-brace.bconf
··· 1 + key1 { 2 + key2 { 3 + key3 { 4 + key4 { 5 + key5 { 6 + key6 { 7 + key7 { 8 + key8 { 9 + key9 { 10 + key10 { 11 + key11 { 12 + key12 { 13 + key13 { 14 + key14 { 15 + key15 { 16 + key16 { 17 + key17 { 18 + }}}}}}}}}}}}}}}}} 19 +
+1
tools/bootconfig/samples/exp-good-nested-brace.bconf
··· 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
··· 1 + key1 { 2 + key2 { 3 + key3 { 4 + key4 { 5 + key5 { 6 + key6 { 7 + key7 { 8 + key8 { 9 + key9 { 10 + key10 { 11 + key11 { 12 + key12 { 13 + key13 { 14 + key14 { 15 + key15 { 16 + key16 { 17 + }}}}}}}}}}}}}}}} 18 +
+9
tools/bootconfig/test-bootconfig.sh
··· 171 171 xfail grep -q 'val[[:space:]]' $OUTFILE 172 172 xpass grep -q 'val2[[:space:]]' $OUTFILE 173 173 174 + echo "Showing correct line:column of no closing brace" 175 + cat > $TEMPCONF << EOF 176 + foo { 177 + bar { 178 + } 179 + EOF 180 + $BOOTCONF -a $TEMPCONF $INITRD 2> $OUTFILE 181 + xpass grep -q "1:1" $OUTFILE 182 + 174 183 echo "=== expected failure cases ===" 175 184 for i in samples/bad-* ; do 176 185 xfail $BOOTCONF -a $i $INITRD