On (15/04/16 14:41), Michal Židek wrote:
>On 03/16/2016 02:04 PM, Michal Židek wrote:
>> Hi,
>>
>> these three patches add infrastructure for this libini feature
>> https://fedorahosted.org/sssd/wiki/DesignDocs/libini-config-file-checks
>>
>> I did not add the patch for ini_allowed_sections validator. Will
>> add that validator when these patches are in master.
>>
>> I also did not bump the version number for now. Will do this
>> before release.
>>
>> Any comments are welcome.
>>
>> Thanks
>>
>> Michal
>>
>
>Found some small issues in the patches so I
>updated them and added ini_allowed_sections
>validator to the patches.
>
>Michal
>
>From 675fe7aef88e2cfe4909c9c0b34e5f498233987b Mon Sep 17 00:00:00 2001
>From: =?UTF-8?q?Michal=20=C5=BDidek?= <[email protected]>
>Date: Wed, 3 Feb 2016 18:51:49 +0100
>Subject: [PATCH 1/4] ini: Add infrastructure for validators
>
>Ticket:
>https://fedorahosted.org/sssd/ticket/133
I found few warnigs reported by static analysers/mostly clang.
They might be related to compile time warnings gcc-6.0
ini/ini_configobj.c: In function ‘ini_allowed_sections’:
ini/ini_configobj.c:1312:5: warning: ‘allowed_sections_re’ may be used
uninitialized in this function [-Wmaybe-uninitialized]
free(allowed_sections_re);
^~~~~~~~~~~~~~~~~~~~~~~~~
ini/ini_configobj.c: In function ‘ini_allowed_options’:
ini/ini_configobj.c:1486:5: warning: ‘sections’ may be used uninitialized in
this function [-Wmaybe-uninitialized]
ini_free_section_list(sections);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Could you check wheter they are real issuses or false positives?
Meanwhile, I will continue with review
@see also attached diff with coding style issues.
Error: FORWARD_NULL (CWE-476): [#def1]
ding-libs-0.5.0/ini/ini_configobj.c:1122: var_deref_model: Passing "NULL" to
"regexec", which dereferences it.
# 1120|
# 1121| for (int i = 0; i < num_sec_re; i++) {
# 1122|-> ret = regexec(&allowed_sections_re[i], tested_section, 0,
NULL, 0);
# 1123| if (ret == 0) {
# 1124| return 1;
Error: CLANG_WARNING: [#def2]
ding-libs-0.5.0/ini/ini_configobj.c:1213:24: warning: Call to 'calloc' has an
allocation size of 0 bytes
# allowed_sections = calloc(num_sec, sizeof(char*));
# ^ ~~~~~~~
ding-libs-0.5.0/ini/ini_configobj.c:1145:5: note: 'num_sec' initialized to 0
# size_t num_sec = 0;
# ^~~~~~~~~~~~~~
ding-libs-0.5.0/ini/ini_configobj.c:1161:9: note: Assuming 'attributes' is not
equal to null
# if (attributes == NULL) {
# ^~~~~~~~~~~~~~~~~~
ding-libs-0.5.0/ini/ini_configobj.c:1161:5: note: Taking false branch
# if (attributes == NULL) {
# ^
ding-libs-0.5.0/ini/ini_configobj.c:1166:21: note: Assuming 'i' is <
'num_attributes'
# for (int i = 0; i < num_attributes; i++) {
# ^~~~~~~~~~~~~~~~~~
ding-libs-0.5.0/ini/ini_configobj.c:1166:5: note: Loop condition is true.
Entering loop body
# for (int i = 0; i < num_attributes; i++) {
# ^
ding-libs-0.5.0/ini/ini_configobj.c:1167:9: note: Taking false branch
# if (strcmp("section", attributes[i]) == 0) {
# ^
ding-libs-0.5.0/ini/ini_configobj.c:1171:9: note: Taking true branch
# if (strcmp("section_re", attributes[i]) == 0) {
# ^
ding-libs-0.5.0/ini/ini_configobj.c:1166:21: note: Assuming 'i' is >=
'num_attributes'
# for (int i = 0; i < num_attributes; i++) {
# ^~~~~~~~~~~~~~~~~~
ding-libs-0.5.0/ini/ini_configobj.c:1166:5: note: Loop condition is false.
Execution continues on line 1176
# for (int i = 0; i < num_attributes; i++) {
# ^
ding-libs-0.5.0/ini/ini_configobj.c:1176:9: note: Left side of '&&' is true
# if (num_sec == 0 && num_sec_re == 0) {
# ^
ding-libs-0.5.0/ini/ini_configobj.c:1176:5: note: Taking false branch
# if (num_sec == 0 && num_sec_re == 0) {
# ^
ding-libs-0.5.0/ini/ini_configobj.c:1191:9: note: Assuming 'ret' is 0
# if (ret) {
# ^~~
ding-libs-0.5.0/ini/ini_configobj.c:1191:5: note: Taking false branch
# if (ret) {
# ^
ding-libs-0.5.0/ini/ini_configobj.c:1195:9: note: Assuming 'vo' is null
# if (vo) {
# ^~
ding-libs-0.5.0/ini/ini_configobj.c:1195:5: note: Taking false branch
# if (vo) {
# ^
ding-libs-0.5.0/ini/ini_configobj.c:1213:24: note: Call to 'calloc' has an
allocation size of 0 bytes
# allowed_sections = calloc(num_sec, sizeof(char*));
# ^ ~~~~~~~
# 1211| /* Create arrays for section_re regexes and section name
# 1212| * strings. */
# 1213|-> allowed_sections = calloc(num_sec, sizeof(char*));
# 1214| if (allowed_sections == NULL) {
# 1215| ret = ENOMEM;
Error: CLANG_WARNING: [#def3]
ding-libs-0.5.0/ini/ini_configobj.c:1219:27: warning: Call to 'calloc' has an
allocation size of 0 bytes
# allowed_sections_re = calloc(num_sec_re, sizeof(regex_t));
# ^ ~~~~~~~~~~
ding-libs-0.5.0/ini/ini_configobj.c:1146:5: note: 'num_sec_re' initialized to 0
# size_t num_sec_re = 0;
# ^~~~~~~~~~~~~~~~~
ding-libs-0.5.0/ini/ini_configobj.c:1161:9: note: Assuming 'attributes' is not
equal to null
# if (attributes == NULL) {
# ^~~~~~~~~~~~~~~~~~
ding-libs-0.5.0/ini/ini_configobj.c:1161:5: note: Taking false branch
# if (attributes == NULL) {
# ^
ding-libs-0.5.0/ini/ini_configobj.c:1166:21: note: Assuming 'i' is <
'num_attributes'
# for (int i = 0; i < num_attributes; i++) {
# ^~~~~~~~~~~~~~~~~~
ding-libs-0.5.0/ini/ini_configobj.c:1166:5: note: Loop condition is true.
Entering loop body
# for (int i = 0; i < num_attributes; i++) {
# ^
ding-libs-0.5.0/ini/ini_configobj.c:1167:9: note: Taking true branch
# if (strcmp("section", attributes[i]) == 0) {
# ^
ding-libs-0.5.0/ini/ini_configobj.c:1171:9: note: Taking false branch
# if (strcmp("section_re", attributes[i]) == 0) {
# ^
ding-libs-0.5.0/ini/ini_configobj.c:1166:21: note: Assuming 'i' is >=
'num_attributes'
# for (int i = 0; i < num_attributes; i++) {
# ^~~~~~~~~~~~~~~~~~
ding-libs-0.5.0/ini/ini_configobj.c:1166:5: note: Loop condition is false.
Execution continues on line 1176
# for (int i = 0; i < num_attributes; i++) {
# ^
ding-libs-0.5.0/ini/ini_configobj.c:1176:22: note: Left side of '&&' is false
# if (num_sec == 0 && num_sec_re == 0) {
# ^
ding-libs-0.5.0/ini/ini_configobj.c:1191:9: note: Assuming 'ret' is 0
# if (ret) {
# ^~~
ding-libs-0.5.0/ini/ini_configobj.c:1191:5: note: Taking false branch
# if (ret) {
# ^
ding-libs-0.5.0/ini/ini_configobj.c:1195:9: note: Assuming 'vo' is null
# if (vo) {
# ^~
ding-libs-0.5.0/ini/ini_configobj.c:1195:5: note: Taking false branch
# if (vo) {
# ^
ding-libs-0.5.0/ini/ini_configobj.c:1214:9: note: Assuming 'allowed_sections'
is not equal to null
# if (allowed_sections == NULL) {
# ^~~~~~~~~~~~~~~~~~~~~~~~
ding-libs-0.5.0/ini/ini_configobj.c:1214:5: note: Taking false branch
# if (allowed_sections == NULL) {
# ^
ding-libs-0.5.0/ini/ini_configobj.c:1219:27: note: Call to 'calloc' has an
allocation size of 0 bytes
# allowed_sections_re = calloc(num_sec_re, sizeof(regex_t));
# ^ ~~~~~~~~~~
# 1217| }
# 1218|
# 1219|-> allowed_sections_re = calloc(num_sec_re, sizeof(regex_t));
# 1220| if (allowed_sections_re == NULL) {
# 1221| ret = ENOMEM;
Error: CLANG_WARNING: [#def4]
ding-libs-0.5.0/ini/ini_configobj.c:1306:14: warning: Array access (from
variable 'allowed_sections') results in a null pointer dereference
# free(allowed_sections[i]);
# ^~~~~~~~~~~~~~~~
ding-libs-0.5.0/ini/ini_configobj.c:1139:5: note: 'allowed_sections'
initialized to a null pointer value
# char **allowed_sections = NULL;
# ^~~~~~~~~~~~~~~~~~~~~~~
ding-libs-0.5.0/ini/ini_configobj.c:1161:9: note: Assuming 'attributes' is not
equal to null
# if (attributes == NULL) {
# ^~~~~~~~~~~~~~~~~~
ding-libs-0.5.0/ini/ini_configobj.c:1161:5: note: Taking false branch
# if (attributes == NULL) {
# ^
ding-libs-0.5.0/ini/ini_configobj.c:1166:21: note: Assuming 'i' is <
'num_attributes'
# for (int i = 0; i < num_attributes; i++) {
# ^~~~~~~~~~~~~~~~~~
ding-libs-0.5.0/ini/ini_configobj.c:1166:5: note: Loop condition is true.
Entering loop body
# for (int i = 0; i < num_attributes; i++) {
# ^
ding-libs-0.5.0/ini/ini_configobj.c:1167:9: note: Taking true branch
# if (strcmp("section", attributes[i]) == 0) {
# ^
ding-libs-0.5.0/ini/ini_configobj.c:1171:9: note: Taking false branch
# if (strcmp("section_re", attributes[i]) == 0) {
# ^
ding-libs-0.5.0/ini/ini_configobj.c:1166:21: note: Assuming 'i' is >=
'num_attributes'
# for (int i = 0; i < num_attributes; i++) {
# ^~~~~~~~~~~~~~~~~~
ding-libs-0.5.0/ini/ini_configobj.c:1166:5: note: Loop condition is false.
Execution continues on line 1176
# for (int i = 0; i < num_attributes; i++) {
# ^
ding-libs-0.5.0/ini/ini_configobj.c:1176:22: note: Left side of '&&' is false
# if (num_sec == 0 && num_sec_re == 0) {
# ^
ding-libs-0.5.0/ini/ini_configobj.c:1191:9: note: Assuming 'ret' is not equal
to 0
# if (ret) {
# ^~~
ding-libs-0.5.0/ini/ini_configobj.c:1191:5: note: Taking true branch
# if (ret) {
# ^
ding-libs-0.5.0/ini/ini_configobj.c:1192:9: note: Control jumps to line 1305
# goto done;
# ^
ding-libs-0.5.0/ini/ini_configobj.c:1305:5: note: Loop condition is true.
Entering loop body
# for (int i = 0; i < num_sec; i++) {
# ^
ding-libs-0.5.0/ini/ini_configobj.c:1306:14: note: Array access (from variable
'allowed_sections') results in a null pointer dereference
# free(allowed_sections[i]);
# ^~~~~~~~~~~~~~~~
# 1304| done:
# 1305| for (int i = 0; i < num_sec; i++) {
# 1306|-> free(allowed_sections[i]);
# 1307| }
# 1308| free(allowed_sections);
Error: CLANG_WARNING: [#def5]
ding-libs-0.5.0/ini/ini_configobj.c:1310:9: warning: Function call argument is
an uninitialized value
# regfree(&allowed_sections_re[i]);
# ^ ~~~~~~~~~~~~~~~~~~~~~~~
ding-libs-0.5.0/ini/ini_configobj.c:1161:9: note: Assuming 'attributes' is not
equal to null
# if (attributes == NULL) {
# ^~~~~~~~~~~~~~~~~~
ding-libs-0.5.0/ini/ini_configobj.c:1161:5: note: Taking false branch
# if (attributes == NULL) {
# ^
ding-libs-0.5.0/ini/ini_configobj.c:1166:21: note: Assuming 'i' is <
'num_attributes'
# for (int i = 0; i < num_attributes; i++) {
# ^~~~~~~~~~~~~~~~~~
ding-libs-0.5.0/ini/ini_configobj.c:1166:5: note: Loop condition is true.
Entering loop body
# for (int i = 0; i < num_attributes; i++) {
# ^
ding-libs-0.5.0/ini/ini_configobj.c:1167:9: note: Taking false branch
# if (strcmp("section", attributes[i]) == 0) {
# ^
ding-libs-0.5.0/ini/ini_configobj.c:1171:9: note: Taking true branch
# if (strcmp("section_re", attributes[i]) == 0) {
# ^
ding-libs-0.5.0/ini/ini_configobj.c:1166:21: note: Assuming 'i' is >=
'num_attributes'
# for (int i = 0; i < num_attributes; i++) {
# ^~~~~~~~~~~~~~~~~~
ding-libs-0.5.0/ini/ini_configobj.c:1166:5: note: Loop condition is false.
Execution continues on line 1176
# for (int i = 0; i < num_attributes; i++) {
# ^
ding-libs-0.5.0/ini/ini_configobj.c:1176:9: note: Left side of '&&' is true
# if (num_sec == 0 && num_sec_re == 0) {
# ^
ding-libs-0.5.0/ini/ini_configobj.c:1176:5: note: Taking false branch
# if (num_sec == 0 && num_sec_re == 0) {
# ^
ding-libs-0.5.0/ini/ini_configobj.c:1191:9: note: Assuming 'ret' is not equal
to 0
# if (ret) {
# ^~~
ding-libs-0.5.0/ini/ini_configobj.c:1191:5: note: Taking true branch
# if (ret) {
# ^
ding-libs-0.5.0/ini/ini_configobj.c:1192:9: note: Control jumps to line 1305
# goto done;
# ^
ding-libs-0.5.0/ini/ini_configobj.c:1305:5: note: Loop condition is false.
Execution continues on line 1308
# for (int i = 0; i < num_sec; i++) {
# ^
ding-libs-0.5.0/ini/ini_configobj.c:1309:5: note: Loop condition is true.
Entering loop body
# for (int i = 0; i < num_sec_re; i++) {
# ^
ding-libs-0.5.0/ini/ini_configobj.c:1310:9: note: Function call argument is an
uninitialized value
# regfree(&allowed_sections_re[i]);
# ^ ~~~~~~~~~~~~~~~~~~~~~~~
# 1308| free(allowed_sections);
# 1309| for (int i = 0; i < num_sec_re; i++) {
# 1310|-> regfree(&allowed_sections_re[i]);
# 1311| }
# 1312| free(allowed_sections_re);
Error: UNINIT (CWE-457): [#def6]
ding-libs-0.5.0/ini/ini_configobj.c:1147: var_decl: Declaring variable
"allowed_sections_re" without initializer.
ding-libs-0.5.0/ini/ini_configobj.c:1312: uninit_use_in_call: Using
uninitialized value "allowed_sections_re" when calling "free".
# 1310| regfree(&allowed_sections_re[i]);
# 1311| }
# 1312|-> free(allowed_sections_re);
# 1313| ini_free_section_list(cfg_sections);
# 1314| free(regex_str);
Error: COMPILER_WARNING: [#def7]
ding-libs-0.5.0/ini/ini_configobj.c: scope_hint: In function
'ini_allowed_sections'
ding-libs-0.5.0/ini/ini_configobj.c:1312:5: warning: 'allowed_sections_re' may
be used uninitialized in this function [-Wmaybe-uninitialized]
# free(allowed_sections_re);
# ^
# 1310| regfree(&allowed_sections_re[i]);
# 1311| }
# 1312|-> free(allowed_sections_re);
# 1313| ini_free_section_list(cfg_sections);
# 1314| free(regex_str);
Error: CLANG_WARNING: [#def8]
ding-libs-0.5.0/ini/ini_configobj.c:1312:5: warning: Function call argument is
an uninitialized value
# free(allowed_sections_re);
# ^ ~~~~~~~~~~~~~~~~~~~
ding-libs-0.5.0/ini/ini_configobj.c:1147:5: note: 'allowed_sections_re'
declared without an initial value
# regex_t *allowed_sections_re;
# ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
ding-libs-0.5.0/ini/ini_configobj.c:1161:9: note: Assuming 'attributes' is not
equal to null
# if (attributes == NULL) {
# ^~~~~~~~~~~~~~~~~~
ding-libs-0.5.0/ini/ini_configobj.c:1161:5: note: Taking false branch
# if (attributes == NULL) {
# ^
ding-libs-0.5.0/ini/ini_configobj.c:1166:21: note: Assuming 'i' is >=
'num_attributes'
# for (int i = 0; i < num_attributes; i++) {
# ^~~~~~~~~~~~~~~~~~
ding-libs-0.5.0/ini/ini_configobj.c:1166:5: note: Loop condition is false.
Execution continues on line 1176
# for (int i = 0; i < num_attributes; i++) {
# ^
ding-libs-0.5.0/ini/ini_configobj.c:1176:9: note: Left side of '&&' is true
# if (num_sec == 0 && num_sec_re == 0) {
# ^
ding-libs-0.5.0/ini/ini_configobj.c:1176:5: note: Taking true branch
# if (num_sec == 0 && num_sec_re == 0) {
# ^
ding-libs-0.5.0/ini/ini_configobj.c:1181:9: note: Control jumps to line 1305
# goto done;
# ^
ding-libs-0.5.0/ini/ini_configobj.c:1305:5: note: Loop condition is false.
Execution continues on line 1308
# for (int i = 0; i < num_sec; i++) {
# ^
ding-libs-0.5.0/ini/ini_configobj.c:1309:5: note: Loop condition is false.
Execution continues on line 1312
# for (int i = 0; i < num_sec_re; i++) {
# ^
ding-libs-0.5.0/ini/ini_configobj.c:1312:5: note: Function call argument is an
uninitialized value
# free(allowed_sections_re);
# ^ ~~~~~~~~~~~~~~~~~~~
# 1310| regfree(&allowed_sections_re[i]);
# 1311| }
# 1312|-> free(allowed_sections_re);
# 1313| ini_free_section_list(cfg_sections);
# 1314| free(regex_str);
Error: RESOURCE_LEAK (CWE-772): [#def9]
ding-libs-0.5.0/ini/ini_configobj.c:1166: start: Starting defect path here.
ding-libs-0.5.0/ini/ini_configobj.c:1263: alloc_fn: Storage is returned from
allocation function "malloc".
ding-libs-0.5.0/ini/ini_configobj.c:1263: var_assign: Assigning: "err_str" =
storage returned from "malloc(buf_size)".
ding-libs-0.5.0/ini/ini_configobj.c:1269: noescape: Resource "err_str" is not
freed or pointed-to in "regerror".
ding-libs-0.5.0/ini/ini_configobj.c:1270: noescape: Resource "err_str" is not
freed or pointed-to in "ini_errobj_add_msg".
ding-libs-0.5.0/ini/ini_configobj.c:1316: leaked_storage: Variable "err_str"
going out of scope leaks the storage it points to.
# 1314| free(regex_str);
# 1315|
# 1316|-> return ret;
# 1317| }
# 1318|
Error: CLANG_WARNING: [#def10]
ding-libs-0.5.0/ini/ini_configobj.c:1433:15: warning: Call to 'calloc' has an
allocation size of 0 bytes
# allowed = calloc(num_opts, sizeof(char *));
# ^ ~~~~~~~~
ding-libs-0.5.0/ini/ini_configobj.c:1354:5: note: 'num_opts' initialized to 0
# int num_opts = 0;
# ^~~~~~~~~~~~
ding-libs-0.5.0/ini/ini_configobj.c:1367:9: note: Assuming 'ret' is equal to 0
# if (ret != 0) {
# ^~~~~~~~
ding-libs-0.5.0/ini/ini_configobj.c:1367:5: note: Taking false branch
# if (ret != 0) {
# ^
ding-libs-0.5.0/ini/ini_configobj.c:1371:9: note: Assuming 'vo' is not equal to
null
# if (vo == NULL) {
# ^~~~~~~~~~
ding-libs-0.5.0/ini/ini_configobj.c:1371:5: note: Taking false branch
# if (vo == NULL) {
# ^
ding-libs-0.5.0/ini/ini_configobj.c:1380:9: note: Assuming 'section_regex' is
not equal to null
# if (section_regex == NULL || section_regex[0] == '\0') {
# ^~~~~~~~~~~~~~~~~~~~~
ding-libs-0.5.0/ini/ini_configobj.c:1380:9: note: Left side of '||' is false
ding-libs-0.5.0/ini/ini_configobj.c:1380:5: note: Taking false branch
# if (section_regex == NULL || section_regex[0] == '\0') {
# ^
ding-libs-0.5.0/ini/ini_configobj.c:1392:9: note: Assuming 'reg_err' is 0
# if (reg_err) {
# ^~~~~~~
ding-libs-0.5.0/ini/ini_configobj.c:1392:5: note: Taking false branch
# if (reg_err) {
# ^
ding-libs-0.5.0/ini/ini_configobj.c:1409:9: note: Assuming 'ret' is equal to 0
# if (ret != EOK) {
# ^~~~~~~~~~
ding-libs-0.5.0/ini/ini_configobj.c:1409:5: note: Taking false branch
# if (ret != EOK) {
# ^
ding-libs-0.5.0/ini/ini_configobj.c:1419:9: note: Assuming 'attributes' is not
equal to null
# if (attributes == NULL) {
# ^~~~~~~~~~~~~~~~~~
ding-libs-0.5.0/ini/ini_configobj.c:1419:5: note: Taking false branch
# if (attributes == NULL) {
# ^
ding-libs-0.5.0/ini/ini_configobj.c:1424:21: note: Assuming 'i' is >=
'num_attributes'
# for (int i = 0; i < num_attributes; i++) {
# ^~~~~~~~~~~~~~~~~~
ding-libs-0.5.0/ini/ini_configobj.c:1424:5: note: Loop condition is false.
Execution continues on line 1430
# for (int i = 0; i < num_attributes; i++) {
# ^
ding-libs-0.5.0/ini/ini_configobj.c:1433:15: note: Call to 'calloc' has an
allocation size of 0 bytes
# allowed = calloc(num_opts, sizeof(char *));
# ^ ~~~~~~~~
# 1431| attributes = NULL;
# 1432|
# 1433|-> allowed = calloc(num_opts, sizeof(char *));
# 1434| if (allowed == NULL) {
# 1435| ret = ENOMEM;
Error: CLANG_WARNING: [#def11]
ding-libs-0.5.0/ini/ini_configobj.c:1483:14: warning: Array access (from
variable 'allowed') results in a null pointer dereference
# free(allowed[i]);
# ^~~~~~~
ding-libs-0.5.0/ini/ini_configobj.c:1367:9: note: Assuming 'ret' is equal to 0
# if (ret != 0) {
# ^~~~~~~~
ding-libs-0.5.0/ini/ini_configobj.c:1367:5: note: Taking false branch
# if (ret != 0) {
# ^
ding-libs-0.5.0/ini/ini_configobj.c:1371:9: note: Assuming 'vo' is not equal to
null
# if (vo == NULL) {
# ^~~~~~~~~~
ding-libs-0.5.0/ini/ini_configobj.c:1371:5: note: Taking false branch
# if (vo == NULL) {
# ^
ding-libs-0.5.0/ini/ini_configobj.c:1380:9: note: Assuming 'section_regex' is
not equal to null
# if (section_regex == NULL || section_regex[0] == '\0') {
# ^~~~~~~~~~~~~~~~~~~~~
ding-libs-0.5.0/ini/ini_configobj.c:1380:9: note: Left side of '||' is false
ding-libs-0.5.0/ini/ini_configobj.c:1380:5: note: Taking false branch
# if (section_regex == NULL || section_regex[0] == '\0') {
# ^
ding-libs-0.5.0/ini/ini_configobj.c:1392:9: note: Assuming 'reg_err' is 0
# if (reg_err) {
# ^~~~~~~
ding-libs-0.5.0/ini/ini_configobj.c:1392:5: note: Taking false branch
# if (reg_err) {
# ^
ding-libs-0.5.0/ini/ini_configobj.c:1409:9: note: Assuming 'ret' is equal to 0
# if (ret != EOK) {
# ^~~~~~~~~~
ding-libs-0.5.0/ini/ini_configobj.c:1409:5: note: Taking false branch
# if (ret != EOK) {
# ^
ding-libs-0.5.0/ini/ini_configobj.c:1419:9: note: Assuming 'attributes' is not
equal to null
# if (attributes == NULL) {
# ^~~~~~~~~~~~~~~~~~
ding-libs-0.5.0/ini/ini_configobj.c:1419:5: note: Taking false branch
# if (attributes == NULL) {
# ^
ding-libs-0.5.0/ini/ini_configobj.c:1424:21: note: Assuming 'i' is <
'num_attributes'
# for (int i = 0; i < num_attributes; i++) {
# ^~~~~~~~~~~~~~~~~~
ding-libs-0.5.0/ini/ini_configobj.c:1424:5: note: Loop condition is true.
Entering loop body
# for (int i = 0; i < num_attributes; i++) {
# ^
ding-libs-0.5.0/ini/ini_configobj.c:1425:9: note: Taking true branch
# if (strcmp("option", attributes[i]) == 0) {
# ^
ding-libs-0.5.0/ini/ini_configobj.c:1424:21: note: Assuming 'i' is >=
'num_attributes'
# for (int i = 0; i < num_attributes; i++) {
# ^~~~~~~~~~~~~~~~~~
ding-libs-0.5.0/ini/ini_configobj.c:1424:5: note: Loop condition is false.
Execution continues on line 1430
# for (int i = 0; i < num_attributes; i++) {
# ^
ding-libs-0.5.0/ini/ini_configobj.c:1433:5: note: Value assigned to 'allowed'
# allowed = calloc(num_opts, sizeof(char *));
# ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ding-libs-0.5.0/ini/ini_configobj.c:1434:9: note: Assuming 'allowed' is equal
to null
# if (allowed == NULL) {
# ^~~~~~~~~~~~~~~
ding-libs-0.5.0/ini/ini_configobj.c:1434:5: note: Taking true branch
# if (allowed == NULL) {
# ^
ding-libs-0.5.0/ini/ini_configobj.c:1436:9: note: Control jumps to line 1482
# goto done;
# ^
ding-libs-0.5.0/ini/ini_configobj.c:1482:5: note: Loop condition is true.
Entering loop body
# for (int i = 0; i < num_opts; i++) {
# ^
ding-libs-0.5.0/ini/ini_configobj.c:1483:14: note: Array access (from variable
'allowed') results in a null pointer dereference
# free(allowed[i]);
# ^~~~~~~
# 1481| done:
# 1482| for (int i = 0; i < num_opts; i++) {
# 1483|-> free(allowed[i]);
# 1484| }
# 1485| free(allowed);
Error: COMPILER_WARNING: [#def12]
ding-libs-0.5.0/ini/ini_configobj.c: scope_hint: In function
'ini_allowed_options'
ding-libs-0.5.0/ini/ini_configobj.c:1486:5: warning: 'sections' may be used
uninitialized in this function [-Wmaybe-uninitialized]
# ini_free_section_list(sections);
# ^
# 1484| }
# 1485| free(allowed);
# 1486|-> ini_free_section_list(sections);
# 1487| free(section_regex);
# 1488| ini_free_attribute_list(attributes);
Error: CLANG_WARNING: [#def13]
ding-libs-0.5.0/ini/ini_configobj.c:1486:5: warning: Function call argument is
an uninitialized value
# ini_free_section_list(sections);
# ^ ~~~~~~~~
ding-libs-0.5.0/ini/ini_configobj.c:1351:5: note: 'sections' declared without
an initial value
# char **sections;
# ^~~~~~~~~~~~~~~
ding-libs-0.5.0/ini/ini_configobj.c:1367:9: note: Assuming 'ret' is equal to 0
# if (ret != 0) {
# ^~~~~~~~
ding-libs-0.5.0/ini/ini_configobj.c:1367:5: note: Taking false branch
# if (ret != 0) {
# ^
ding-libs-0.5.0/ini/ini_configobj.c:1371:9: note: Assuming 'vo' is not equal to
null
# if (vo == NULL) {
# ^~~~~~~~~~
ding-libs-0.5.0/ini/ini_configobj.c:1371:5: note: Taking false branch
# if (vo == NULL) {
# ^
ding-libs-0.5.0/ini/ini_configobj.c:1380:9: note: Assuming 'section_regex' is
not equal to null
# if (section_regex == NULL || section_regex[0] == '\0') {
# ^~~~~~~~~~~~~~~~~~~~~
ding-libs-0.5.0/ini/ini_configobj.c:1380:9: note: Left side of '||' is false
ding-libs-0.5.0/ini/ini_configobj.c:1380:5: note: Taking false branch
# if (section_regex == NULL || section_regex[0] == '\0') {
# ^
ding-libs-0.5.0/ini/ini_configobj.c:1392:9: note: Assuming 'reg_err' is not
equal to 0
# if (reg_err) {
# ^~~~~~~
ding-libs-0.5.0/ini/ini_configobj.c:1392:5: note: Taking true branch
# if (reg_err) {
# ^
ding-libs-0.5.0/ini/ini_configobj.c:1395:13: note: Assuming 'err_str' is equal
to null
# if (err_str == NULL) {
# ^~~~~~~~~~~~~~~
ding-libs-0.5.0/ini/ini_configobj.c:1395:9: note: Taking true branch
# if (err_str == NULL) {
# ^
ding-libs-0.5.0/ini/ini_configobj.c:1397:13: note: Control jumps to line 1482
# goto done;
# ^
ding-libs-0.5.0/ini/ini_configobj.c:1482:5: note: Loop condition is false.
Execution continues on line 1485
# for (int i = 0; i < num_opts; i++) {
# ^
ding-libs-0.5.0/ini/ini_configobj.c:1486:5: note: Function call argument is an
uninitialized value
# ini_free_section_list(sections);
# ^ ~~~~~~~~
# 1484| }
# 1485| free(allowed);
# 1486|-> ini_free_section_list(sections);
# 1487| free(section_regex);
# 1488| ini_free_attribute_list(attributes);
Error: CLANG_WARNING: [#def14]
ding-libs-0.5.0/ini/ini_configobj.c:1488:5: warning: Function call argument is
an uninitialized value
# ini_free_attribute_list(attributes);
# ^ ~~~~~~~~~~
ding-libs-0.5.0/ini/ini_configobj.c:1352:5: note: 'attributes' declared without
an initial value
# char **attributes;
# ^~~~~~~~~~~~~~~~~
ding-libs-0.5.0/ini/ini_configobj.c:1367:9: note: Assuming 'ret' is equal to 0
# if (ret != 0) {
# ^~~~~~~~
ding-libs-0.5.0/ini/ini_configobj.c:1367:5: note: Taking false branch
# if (ret != 0) {
# ^
ding-libs-0.5.0/ini/ini_configobj.c:1371:9: note: Assuming 'vo' is not equal to
null
# if (vo == NULL) {
# ^~~~~~~~~~
ding-libs-0.5.0/ini/ini_configobj.c:1371:5: note: Taking false branch
# if (vo == NULL) {
# ^
ding-libs-0.5.0/ini/ini_configobj.c:1380:9: note: Assuming 'section_regex' is
not equal to null
# if (section_regex == NULL || section_regex[0] == '\0') {
# ^~~~~~~~~~~~~~~~~~~~~
ding
LS
diff --git a/ini/ini_configobj.c b/ini/ini_configobj.c
index c53e868..be92aea 100644
--- a/ini/ini_configobj.c
+++ b/ini/ini_configobj.c
@@ -1063,7 +1063,7 @@ int ini_read_rules_from_file(const char *filename,
goto done;
}
- ret = ini_config_parse(cfgfile, 0 , INI_MV1S_ALLOW, 0, *_rules_obj);
+ ret = ini_config_parse(cfgfile, 0, INI_MV1S_ALLOW, 0, *_rules_obj);
if (ret != EOK) {
goto done;
}
@@ -1111,7 +1111,7 @@ static int is_allowed_section(const char *tested_section,
}
}
} else { /* case insensitive */
- for (int i = 0; i < num_sec; i++) {
+ for (int i = 0; i < num_sec; i++) {
if (strcmp(tested_section, allowed_sections[i]) == 0) {
return 1;
}
@@ -1185,9 +1185,9 @@ static int ini_allowed_sections(const char *rule_name,
ret = ini_get_config_valueobj(rule_name,
"case_insensitive",
- rules_obj,
- INI_GET_NEXT_VALUE,
- &vo);
+ rules_obj,
+ INI_GET_NEXT_VALUE,
+ &vo);
if (ret) {
goto done;
}
@@ -1225,11 +1225,11 @@ static int ini_allowed_sections(const char *rule_name,
/* Get all allowed section names and store them to
* allowed_sections array */
for (size_t i = 0; i < num_sec; i++) {
- ret = ini_get_config_valueobj(rule_name,
- "section",
- rules_obj,
- INI_GET_NEXT_VALUE,
- &vo);
+ ret = ini_get_config_valueobj(rule_name,
+ "section",
+ rules_obj,
+ INI_GET_NEXT_VALUE,
+ &vo);
if (ret) {
goto done;
}
@@ -1243,11 +1243,11 @@ static int ini_allowed_sections(const char *rule_name,
/* Get all regular section_re regular expresions and
* store them to allowed_sections_re array */
for (int i = 0; i < num_sec_re; i++) {
- ret = ini_get_config_valueobj(rule_name,
- "section_re",
- rules_obj,
- INI_GET_NEXT_VALUE,
- &vo);
+ ret = ini_get_config_valueobj(rule_name,
+ "section_re",
+ rules_obj,
+ INI_GET_NEXT_VALUE,
+ &vo);
if (ret) {
goto done;
}
@@ -1407,7 +1407,7 @@ static int ini_allowed_options(const char *rule_name,
/* Get all sections from config_obj */
sections = ini_get_section_list(config_obj, &num_sections, &ret);
if (ret != EOK) {
- goto done;;
+ goto done;
}
/* Get number of 'option' attributes in this rule
@@ -1491,8 +1491,6 @@ done:
return ret;
}
-
-
static ini_validator_func *
get_validator(char *validator_name,
struct ini_validator *validators,
@@ -1747,4 +1745,3 @@ size_t ini_errobj_count(struct ini_errobj *errobj)
{
return errobj->count;
}
-
diff --git a/ini/ini_configobj.h b/ini/ini_configobj.h
index 0b82d44..d03511b 100644
--- a/ini/ini_configobj.h
+++ b/ini/ini_configobj.h
@@ -2218,7 +2218,6 @@ int ini_rules_check(struct ini_cfgobj *rules_obj,
*/
void ini_rules_destroy(struct ini_cfgobj *ini_config);
-
/**
* @}
*/
diff --git a/ini/ini_validators_ut_check.c b/ini/ini_validators_ut_check.c
index d337d36..6db011f 100644
--- a/ini/ini_validators_ut_check.c
+++ b/ini/ini_validators_ut_check.c
@@ -143,7 +143,6 @@ START_TEST(test_ini_errobj)
}
END_TEST
-
START_TEST(test_ini_noerror)
{
struct ini_cfgobj *rules_obj;
@@ -250,17 +249,17 @@ START_TEST(test_unknown_validator)
END_TEST
static int custom_noerror(const char *rule_name,
- struct ini_cfgobj *rules_obj,
- struct ini_cfgobj *config_obj,
- struct ini_errobj *errobj)
+ struct ini_cfgobj *rules_obj,
+ struct ini_cfgobj *config_obj,
+ struct ini_errobj *errobj)
{
return 0;
}
static int custom_error(const char *rule_name,
- struct ini_cfgobj *rules_obj,
- struct ini_cfgobj *config_obj,
- struct ini_errobj *errobj)
+ struct ini_cfgobj *rules_obj,
+ struct ini_cfgobj *config_obj,
+ struct ini_errobj *errobj)
{
return ini_errobj_add_msg(errobj, "Error");
}
@@ -271,7 +270,7 @@ START_TEST(test_custom_noerror)
struct ini_cfgobj *cfg_obj;
struct ini_errobj *errobj;
int ret;
- struct ini_validator noerror = {"custom_noerror", custom_noerror};
+ struct ini_validator noerror = { "custom_noerror", custom_noerror };
char input_rules[] =
"[rule/custom_succeed]\n"
@@ -306,7 +305,7 @@ START_TEST(test_custom_error)
struct ini_cfgobj *cfg_obj;
struct ini_errobj *errobj;
int ret;
- struct ini_validator error = {"custom_error", custom_error};
+ struct ini_validator error = { "custom_error", custom_error };
const char *errmsg;
char input_rules[] =
@@ -551,7 +550,6 @@ START_TEST(test_ini_allowed_sections_str_typos)
num_err = ini_errobj_count(errobj);
fail_unless(num_err == 2, "Expected 2 errors, got %d", num_err);
-
ini_errobj_destroy(&errobj);
ini_config_destroy(cfg_obj);
ini_rules_destroy(rules_obj);
@@ -674,7 +672,6 @@ START_TEST(test_ini_allowed_sections_re_typos)
num_err = ini_errobj_count(errobj);
fail_unless(num_err == 2, "Expected 2 errors, got %d", num_err);
-
ini_errobj_destroy(&errobj);
ini_config_destroy(cfg_obj);
ini_rules_destroy(rules_obj);
@@ -722,7 +719,6 @@ START_TEST(test_ini_allowed_sections_re_insensitive)
}
END_TEST
-
static Suite *ini_validators_utils_suite(void)
{
Suite *s = suite_create("ini_validators");
@@ -748,7 +744,6 @@ static Suite *ini_validators_utils_suite(void)
tcase_add_test(tc_allowed_options, test_ini_allowed_sections_re_typos);
tcase_add_test(tc_allowed_options,
test_ini_allowed_sections_re_insensitive);
-
suite_add_tcase(s, tc_infrastructure);
suite_add_tcase(s, tc_allowed_options);
suite_add_tcase(s, tc_allowed_sections);
_______________________________________________
sssd-devel mailing list
[email protected]
https://lists.fedorahosted.org/admin/lists/[email protected]