#define SDDL_FLAG_EXPECTING_PAREN 64
#define SDDL_FLAG_EXPECTING_END 128
#define SDDL_FLAG_EXPECTING_PAREN_LITERAL 256
+#define SDDL_FLAG_NOT_EXPECTING_END_PAREN 512
#define SDDL_FLAG_IS_UNARY_OP (1 << 20)
#define SDDL_FLAG_IS_BINARY_OP (1 << 21)
comp->state = SDDL_FLAGS_EXPR_START;
DBG_INFO("%3"PRIu32": (\n", comp->offset);
+ comp->state |= SDDL_FLAG_NOT_EXPECTING_END_PAREN;
+
while (comp->offset < comp->length) {
uint8_t c;
ok = eat_whitespace(comp, false);
"operator lacks right hand argument");
return false;
}
+ if (comp->state & SDDL_FLAG_NOT_EXPECTING_END_PAREN) {
+ /*
+ * You can't have "( )"
+ */
+ comp_error(comp, "empty expression");
+ return false;
+ }
break;
} else if (c == '@') {
ok = parse_attr2(comp);
ALLOW_CHECK(0x10);
}
-
static void test_horrible_fuzz_derived_test_3(void **state)
-{
- INIT();
- USER_SIDS("WD", "AA", "IS");
- SD("S:PPPPPPD:(XD;OI;0x1;;;IS;())(OL;;GR;;;S-1-5-75-552)");
- DENY_CHECK(0x1);
-}
-
-static void test_horrible_fuzz_derived_test_4(void **state)
{
INIT();
USER_SIDS("WD", "AA", "IS");
cmocka_unit_test(test_not_Not_Any_of_1),
cmocka_unit_test(test_not_any_of_composite_1),
cmocka_unit_test(test_resource_ace_single),
- cmocka_unit_test(test_horrible_fuzz_derived_test_4),
cmocka_unit_test(test_horrible_fuzz_derived_test_3),
cmocka_unit_test(test_Device_Member_of_and_Member_of),
cmocka_unit_test(test_resource_ace_multi),
* These expressions should fail to parse.
*/
static const char *sddl[] = {
+ /* '!' is only allowed before parens or @attr */
"(!!! !!! !!! Not_Member_of{SID(AA)}))",
+ /* overflowing numbers can't be sensibly interpreted */
("(@Device.bb == 055555624677746777766777767)"),
("(@Device.bb == 0x624677746777766777767)"),
("(@Device.bb == 624677746777766777767)"),
+ /* insufficient arguments */
"(!)",
"(x >)",
+ "(> 3)",
+ /* keyword as local attribute name */
"( Member_of Contains 3)",
+ /* no parens */
" x < 3",
+ /* wants '==' */
"( x = SID(BA))",
+ /* invalid SID strings */
"( x == SID(ZZ))",
+ "( x == SID(S-1-))",
"( x == SID())",
+ /* literal on LHS */
"(\"x\" == \"x\")",
+ /* odd number of digits following '#' */
"(OctetStringType==#1#2#3##))",
};
size_t i, length;