This patch adds return value checks to function
yaml_parser_initialize() and fopen() under lustre_cfg.c
And funciton cYAML_build_tree() under cyaml.c
Test-Parameters: trivial
CoverityID: 410239 ("Unchecked return value")
CoverityID: 410238 ("Unchecked return value")
Fixes:
65062463 (LU-14359 hsm: support a flatter HSM archive format)
Fixes:
8961f2d8 (LU-4939 utils: allow configuration through yaml files)
Change-Id: I67a34adee3e4d25f97244487684a613426637a70
Signed-off-by: Arshad Hussain <arshad.hussain@aeoncomputing.com>
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/53331
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Chris Horn <chris.horn@hpe.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
bool debug)
{
yaml_parser_t parser;
- struct cYAML *yaml;
+ struct cYAML *yaml = NULL;
char err_str[256];
FILE *input = NULL;
/* Create the Parser object. */
- yaml_parser_initialize(&parser);
+ if (yaml_parser_initialize(&parser) == 0)
+ goto out_init;
/* file always takes precedence */
if (path != NULL) {
if (input != NULL)
fclose(input);
-
+out_init:
return yaml;
}
convert = !strncmp(func, "set_param", 9);
file = fopen(filename, "rb");
- yaml_parser_initialize(&parser);
+ if (!file) {
+ rc1 = -errno;
+ goto out_open;
+ }
+
+ rc = yaml_parser_initialize(&parser);
+ if (rc == 0) {
+ rc1 = -EOPNOTSUPP;
+ goto out_init;
+ }
yaml_parser_set_input_file(&parser, file);
/*
}
yaml_parser_delete(&parser);
+out_init:
fclose(file);
-
+out_open:
return rc1;
}