summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitri Pal <dpal@redhat.com>2010-06-10 12:19:01 -0400
committerStephen Gallagher <sgallagh@redhat.com>2010-06-28 08:38:14 -0400
commit9d3bd4b906fbfc879cec06d9cdad44db7c15c5ff (patch)
tree5ccd4d5b22a3c532436f52c97022d4805f15d325
parent3e4f712b7c6009a654757f9900d7b1e0ffc2a6d3 (diff)
downloadsssd-9d3bd4b906fbfc879cec06d9cdad44db7c15c5ff.tar.gz
sssd-9d3bd4b906fbfc879cec06d9cdad44db7c15c5ff.tar.xz
sssd-9d3bd4b906fbfc879cec06d9cdad44db7c15c5ff.zip
Fixing NULL dereferencing in ini_config
Addressing ticket #504 Conflicts: common/ini/ini_config.c
-rw-r--r--common/ini/ini_config.c54
1 files changed, 32 insertions, 22 deletions
diff --git a/common/ini/ini_config.c b/common/ini/ini_config.c
index b9cd6eb06..7ed82b186 100644
--- a/common/ini/ini_config.c
+++ b/common/ini/ini_config.c
@@ -219,19 +219,24 @@ static int ini_to_collection(FILE *file,
break;
case RET_ERROR:
- pe.line = line;
- pe.error = ext_err;
- error = col_add_binary_property(*error_list, NULL,
- ERROR_TXT, &pe, sizeof(pe));
- if (error) {
- TRACE_ERROR_NUMBER("Failed to add error to collection", error);
- col_destroy_collection(current_section);
- if (created) {
- col_destroy_collection(*error_list);
- *error_list = NULL;
+ /* Try to add to the error list only if it is present */
+ if (error_list) {
+ pe.line = line;
+ pe.error = ext_err;
+ error = col_add_binary_property(*error_list, NULL,
+ ERROR_TXT, &pe, sizeof(pe));
+ if (error) {
+ TRACE_ERROR_NUMBER("Failed to add error to collection",
+ error);
+ col_destroy_collection(current_section);
+ if (created) {
+ col_destroy_collection(*error_list);
+ *error_list = NULL;
+ }
+ return error;
}
- return error;
}
+
/* Exit if there was an error parsing file */
if (error_level != INI_STOP_ON_NONE) {
TRACE_ERROR_STRING("Invalid format of the file", "");
@@ -242,19 +247,24 @@ static int ini_to_collection(FILE *file,
case RET_INVALID:
default:
- pe.line = line;
- pe.error = ext_err;
- error = col_add_binary_property(*error_list, NULL,
- WARNING_TXT, &pe, sizeof(pe));
- if (error) {
- TRACE_ERROR_NUMBER("Failed to add warning to collection", error);
- col_destroy_collection(current_section);
- if (created) {
- col_destroy_collection(*error_list);
- *error_list = NULL;
+ /* Try to add to the error list only if it is present */
+ if (error_list) {
+ pe.line = line;
+ pe.error = ext_err;
+ error = col_add_binary_property(*error_list, NULL,
+ WARNING_TXT, &pe, sizeof(pe));
+ if (error) {
+ TRACE_ERROR_NUMBER("Failed to add warning to collection",
+ error);
+ col_destroy_collection(current_section);
+ if (created) {
+ col_destroy_collection(*error_list);
+ *error_list = NULL;
+ }
+ return error;
}
- return error;
}
+
/* Exit if we are told to exit on warnings */
if (error_level == INI_STOP_ON_ANY) {
TRACE_ERROR_STRING("Invalid format of the file", "");