to prevent crash on syntax error - add 0007-Simplify-and-fix-parsing-of-etc-SuSE-release-fixes-i.patch * add 'suse' class for consistency with other vendor classes (fixes #5417) * distinction between "SUSE Linux Enterprise Server" (sles) and "... Desktop" (sled) * distinction between SUSE Linux Enterprise products (suse) and openSUSE (opensuse) * extract version from VERSION and PATCHLEVEL lines instead of first line of /etc/SuSE-release - merge cfengine-server with cfengine. A policy server only gets cfengine-masterfiles but is otherwise identical to a client. OBS-URL: https://build.opensuse.org/package/show/systemsmanagement/cfengine?expand=0&rev=89
85 lines
4.1 KiB
Diff
85 lines
4.1 KiB
Diff
From cc963ee8af0408d902c7956414c4d1c54a902805 Mon Sep 17 00:00:00 2001
|
|
From: Sigurd Teigen <sigurd.teigen@cfengine.com>
|
|
Date: Tue, 8 Apr 2014 12:53:04 -0400
|
|
Subject: [PATCH 2/7] Do not segfault on type checking NULL Rvals.
|
|
|
|
Add unit test. Close #5416
|
|
---
|
|
diff -wruN -x '*~' -x '*.o' -x '*.a' -x '*.so' -x '*.so.[0-9]' -x autom4te.cache -x .deps -x .libs ../orig-core-3.6.0b2/libpromises/syntax.c ./libpromises/syntax.c
|
|
--- ../orig-core-3.6.0b2/libpromises/syntax.c 2014-03-17 17:37:49.000000000 +0100
|
|
+++ ./libpromises/syntax.c 2014-04-10 16:12:06.104406735 +0200
|
|
@@ -253,10 +253,11 @@
|
|
[SYNTAX_TYPE_MATCH_OK] = "OK",
|
|
|
|
[SYNTAX_TYPE_MATCH_ERROR_UNEXPANDED] = "Cannot check unexpanded value",
|
|
- [SYNTAX_TYPE_MATCH_ERROR_RANGE_BRACKETED] = "Real range specification should not be enclosed in brackets - just \"a,b\"",
|
|
- [SYNTAX_TYPE_MATCH_ERROR_RANGE_MULTIPLE_ITEMS] = "Range format specifier should be of form \"a,b\" but got multiple items",
|
|
+ [SYNTAX_TYPE_MATCH_ERROR_RANGE_BRACKETED] = "Real range specification should not be enclosed in brackets - just 'a,b'",
|
|
+ [SYNTAX_TYPE_MATCH_ERROR_RANGE_MULTIPLE_ITEMS] = "Range format specifier should be of form 'a,b'' but got multiple items",
|
|
[SYNTAX_TYPE_MATCH_ERROR_GOT_SCALAR] = "Attempted to give a scalar to a non-scalar type",
|
|
[SYNTAX_TYPE_MATCH_ERROR_GOT_LIST] = "Attempted to give a list to a non-list type",
|
|
+ [SYNTAX_TYPE_MATCH_ERROR_GOT_NULL] = "Attempted to give a value of type null",
|
|
|
|
[SYNTAX_TYPE_MATCH_ERROR_STRING_UNIX_PERMISSION] = "Error parsing Unix permission string",
|
|
|
|
@@ -266,7 +267,7 @@
|
|
[SYNTAX_TYPE_MATCH_ERROR_INT_PARSE] = "Cannot parse value as integer",
|
|
[SYNTAX_TYPE_MATCH_ERROR_INT_OUT_OF_RANGE] = "Integer is out of range",
|
|
|
|
- [SYNTAX_TYPE_MATCH_ERROR_REAL_INF] = "Keyword \"inf\" has an integer value, cannot be used as real",
|
|
+ [SYNTAX_TYPE_MATCH_ERROR_REAL_INF] = "Keyword 'inf' has an integer value, cannot be used as real",
|
|
[SYNTAX_TYPE_MATCH_ERROR_REAL_OUT_OF_RANGE] = "Real value is out of range",
|
|
|
|
[SYNTAX_TYPE_MATCH_ERROR_OPTS_OUT_OF_RANGE] = "Selection is out of bounds",
|
|
@@ -355,8 +356,10 @@
|
|
return SYNTAX_TYPE_MATCH_OK;
|
|
|
|
case RVAL_TYPE_CONTAINER:
|
|
- case RVAL_TYPE_NOPROMISEE:
|
|
break;
|
|
+
|
|
+ case RVAL_TYPE_NOPROMISEE:
|
|
+ return SYNTAX_TYPE_MATCH_ERROR_GOT_NULL;
|
|
}
|
|
|
|
/* If we get here, we have a literal scalar type */
|
|
diff -wruN -x '*~' -x '*.o' -x '*.a' -x '*.so' -x '*.so.[0-9]' -x autom4te.cache -x .deps -x .libs ../orig-core-3.6.0b2/libpromises/syntax.h ./libpromises/syntax.h
|
|
--- ../orig-core-3.6.0b2/libpromises/syntax.h 2014-03-17 17:37:49.000000000 +0100
|
|
+++ ./libpromises/syntax.h 2014-04-10 16:12:06.104406735 +0200
|
|
@@ -46,6 +46,7 @@
|
|
SYNTAX_TYPE_MATCH_ERROR_RANGE_MULTIPLE_ITEMS,
|
|
SYNTAX_TYPE_MATCH_ERROR_GOT_SCALAR,
|
|
SYNTAX_TYPE_MATCH_ERROR_GOT_LIST,
|
|
+ SYNTAX_TYPE_MATCH_ERROR_GOT_NULL,
|
|
|
|
SYNTAX_TYPE_MATCH_ERROR_SCALAR_OUT_OF_RANGE,
|
|
SYNTAX_TYPE_MATCH_ERROR_EMPTY_SCALAR_OUT_OF_RANGE,
|
|
diff -wruN -x '*~' -x '*.o' -x '*.a' -x '*.so' -x '*.so.[0-9]' -x autom4te.cache -x .deps -x .libs ../orig-core-3.6.0b2/tests/unit/syntax_test.c ./tests/unit/syntax_test.c
|
|
--- ../orig-core-3.6.0b2/tests/unit/syntax_test.c 2014-03-17 17:37:49.000000000 +0100
|
|
+++ ./tests/unit/syntax_test.c 2014-04-10 16:13:24.055666621 +0200
|
|
@@ -88,6 +88,13 @@
|
|
assert_string_equal("delete_if_startwith_from_list", y->lval);
|
|
}
|
|
|
|
+static void test_typecheck_null_rval(void)
|
|
+{
|
|
+ SyntaxTypeMatch err = CheckConstraintTypeMatch("whatever", (Rval) { NULL, RVAL_TYPE_NOPROMISEE },
|
|
+ CF_DATA_TYPE_STRING, "abc", 0);
|
|
+ assert_int_equal(SYNTAX_TYPE_MATCH_ERROR_GOT_NULL, err);
|
|
+}
|
|
+
|
|
int main()
|
|
{
|
|
PRINT_TEST_BANNER();
|
|
@@ -105,7 +112,9 @@
|
|
unit_test(test_lookup_body_process_count),
|
|
unit_test(test_lookup_body_delete_select),
|
|
|
|
- unit_test(test_lookup_constraint_edit_xml_set_attribute_attribute_value)
|
|
+ unit_test(test_lookup_constraint_edit_xml_set_attribute_attribute_value),
|
|
+
|
|
+ unit_test(test_typecheck_null_rval)
|
|
};
|
|
|
|
return run_tests(tests);
|