Skip to content

Commit

Permalink
lib/base: heim_config_parse_debug doesn't return com_err table errors
Browse files Browse the repository at this point in the history
A non-zero return value from heim_config_parse_debug() means there
was an failure to open or parse the configuration data.  However, it
is not necessarily an error code.  Callers when setting an error
message must use an error code.

This change to heim_config_parse_file_multi() and
heim_config_parse_string_multi() set an error code of
HEIM_ERR_CONFIG_BADFORMAT when setting the error message.

Change-Id: I534b9af1c50e32d79799a936cb6252dab99c2a64
  • Loading branch information
jaltman committed May 26, 2020
1 parent 6179a6a commit 55b4a5e
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions lib/base/config_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -667,8 +667,11 @@ heim_config_parse_file_multi(heim_context context,
config_include_depth--;
fclose(f.f);
if (ret) {
heim_set_error_message(context, ret, "%s:%u: %s",
fname, lineno, str);
if (ret != HEIM_ERR_CONFIG_BADFORMAT) {
ret = HEIM_ERR_CONFIG_BADFORMAT;
heim_set_error_message(context, ret, "%s:%u: %s",
fname, lineno, str);
}
free(newfname);
return ret;
}
Expand Down Expand Up @@ -1462,8 +1465,11 @@ heim_config_parse_string_multi(heim_context context,

ret = heim_config_parse_debug(&f, res, &lineno, &str);
if (ret) {
heim_set_error_message(context, ret, "%s:%u: %s",
"<constant>", lineno, str);
if (ret != HEIM_ERR_CONFIG_BADFORMAT) {
ret = HEIM_ERR_CONFIG_BADFORMAT;
heim_set_error_message(context, ret, "%s:%u: %s",
"<constant>", lineno, str);
}
return ret;
}
return 0;
Expand Down

0 comments on commit 55b4a5e

Please sign in to comment.