aboutsummaryrefslogtreecommitdiff
path: root/src/tests
diff options
context:
space:
mode:
authorYaroslav de la Peña Smirnov <yps@yaroslavps.com>2021-11-08 17:44:18 +0300
committerYaroslav de la Peña Smirnov <yps@yaroslavps.com>2021-11-08 17:44:18 +0300
commit6b35ae81a38573dcc42a944ebd8c2e6317cf5ad3 (patch)
treed9118b0db831d878db8acd33f7a69a0dbbf96849 /src/tests
parentdc6d7befaa0de08814d4aaf85838faaf3fec8671 (diff)
downloadparcini-6b35ae81a38573dcc42a944ebd8c2e6317cf5ad3.tar.gz
parcini-6b35ae81a38573dcc42a944ebd8c2e6317cf5ad3.zip
slicecpy: fix buffer overflowHEADmaster
on sections shorter than 3 chars.
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/parcini.c38
1 files changed, 32 insertions, 6 deletions
diff --git a/src/tests/parcini.c b/src/tests/parcini.c
index 90d5997..7511115 100644
--- a/src/tests/parcini.c
+++ b/src/tests/parcini.c
@@ -53,7 +53,7 @@ test_parcini_parse_file(void)
res = parcini_parse_next_line(parser, &line);
asserteq(res, PARCINI_SECTION);
asserteq(line.lineno, 6);
- asserteq(strcmp(line.section, "asection"), 0);
+ asserteq(strcmp(line.section, "s"), 0);
asserteq(line.key, NULL);
asserteq(line.value.type, PARCINI_VALUE_NONE);
@@ -61,7 +61,7 @@ test_parcini_parse_file(void)
res = parcini_parse_next_line(parser, &line);
asserteq(res, PARCINI_KEYVALUE);
asserteq(line.lineno, 7);
- asserteq(strcmp(line.section, "asection"), 0);
+ asserteq(strcmp(line.section, "s"), 0);
asserteq(strcmp(line.key, "skey"), 0);
asserteq(line.value.type, PARCINI_VALUE_STRING);
asserteq(strcmp(line.value.value.string, "ur 2 slow"), 0);
@@ -90,7 +90,7 @@ test_parcini_parse_file(void)
res = parcini_parse_next_line(parser, &line);
asserteq(res, PARCINI_KEYVALUE);
asserteq(line.lineno, 12);
- asserteq(strcmp(line.section, "asection"), 0);
+ asserteq(strcmp(line.section, "s"), 0);
asserteq(strcmp(line.key, "bool2"), 0);
asserteq(line.value.type, PARCINI_VALUE_BOOLEAN);
asserteq(line.value.value.boolean, true);
@@ -99,7 +99,7 @@ test_parcini_parse_file(void)
res = parcini_parse_next_line(parser, &line);
asserteq(res, PARCINI_KEYVALUE);
asserteq(line.lineno, 13);
- asserteq(strcmp(line.section, "asection"), 0);
+ asserteq(strcmp(line.section, "s"), 0);
asserteq(strcmp(line.key, "bool3"), 0);
asserteq(line.value.type, PARCINI_VALUE_BOOLEAN);
asserteq(line.value.value.boolean, false);
@@ -108,7 +108,7 @@ test_parcini_parse_file(void)
res = parcini_parse_next_line(parser, &line);
asserteq(res, PARCINI_KEYVALUE);
asserteq(line.lineno, 14);
- asserteq(strcmp(line.section, "asection"), 0);
+ asserteq(strcmp(line.section, "s"), 0);
asserteq(strcmp(line.key, "bool3"), 0);
asserteq(line.value.type, PARCINI_VALUE_BOOLEAN);
asserteq(line.value.value.boolean, true);
@@ -125,8 +125,34 @@ test_parcini_parse_file(void)
/* line 17 */
res = parcini_parse_next_line(parser, &line);
- asserteq(res, PARCINI_SECTION_PARSE_ERROR);
+ asserteq(res, PARCINI_SECTION);
asserteq(line.lineno, 17);
+ asserteq(strcmp(line.section, "se"), 0);
+ asserteq(line.key, NULL);
+ asserteq(line.value.type, PARCINI_VALUE_NONE);
+
+ /* line 18 */
+ res = parcini_parse_next_line(parser, &line);
+ asserteq(res, PARCINI_EMPTY_LINE);
+ asserteq(line.lineno, 18);
+
+ /* line 19 */
+ res = parcini_parse_next_line(parser, &line);
+ asserteq(res, PARCINI_SECTION_PARSE_ERROR);
+ asserteq(line.lineno, 19);
+
+ /* line 20 */
+ res = parcini_parse_next_line(parser, &line);
+ asserteq(res, PARCINI_EMPTY_LINE);
+ asserteq(line.lineno, 20);
+
+ /* line 21 */
+ res = parcini_parse_next_line(parser, &line);
+ asserteq(res, PARCINI_SECTION);
+ asserteq(line.lineno, 21);
+ asserteq(strcmp(line.section, "section"), 0);
+ asserteq(line.key, NULL);
+ asserteq(line.value.type, PARCINI_VALUE_NONE);
/* EOF */
res = parcini_parse_next_line(parser, &line);