summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitri Pal <dpal@redhat.com>2010-06-09 14:28:48 -0400
committerStephen Gallagher <sgallagh@redhat.com>2010-06-10 10:17:21 -0400
commit0b67f531ca2c0a632e3b2c12095fb005ff528fa8 (patch)
tree6519699675198fdca9a6c0704cd1b724f30494ff
parent3076587434951c3f76f4a5a4893dcc9b6f3713d8 (diff)
downloadsssd-0b67f531ca2c0a632e3b2c12095fb005ff528fa8.tar.gz
sssd-0b67f531ca2c0a632e3b2c12095fb005ff528fa8.tar.xz
sssd-0b67f531ca2c0a632e3b2c12095fb005ff528fa8.zip
Fixing NULL dereferencing in ini_config
Addressing ticket #504
-rw-r--r--common/ini/ini_config.c58
1 files changed, 34 insertions, 24 deletions
diff --git a/common/ini/ini_config.c b/common/ini/ini_config.c
index bd8f88b2c..26d2d4cb9 100644
--- a/common/ini/ini_config.c
+++ b/common/ini/ini_config.c
@@ -364,20 +364,25 @@ 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);
- fclose(file);
- 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);
+ fclose(file);
+ 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", "");
@@ -389,20 +394,25 @@ 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);
- fclose(file);
- 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);
+ fclose(file);
+ 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", "");