Commit f0f4940c authored by npzacs's avatar npzacs
Browse files

Check str_printf() failures

parent 8b9be956
......@@ -54,9 +54,13 @@ static int _mkpath(const char *path)
{
struct stat s;
int result = 1;
char *dir = str_printf("%s", path);
char *dir = str_dup(path);
char *end = dir;
if (!dir) {
return -1;
}
#ifdef _WIN32
end += 2; /* skip drive */
#endif
......@@ -161,6 +165,9 @@ static FILE *_open_cfg_file_system(const char *file_name, char **path)
while (NULL != (dir = file_get_config_system(dir))) {
char *cfg_file = str_printf("%s"DIR_SEP"%s"DIR_SEP"%s", dir, CFG_DIR, file_name);
if (!cfg_file) {
continue;
}
FILE *fp = fopen(cfg_file, "r");
if (fp) {
......@@ -416,7 +423,7 @@ int keycache_find(const char *type, const uint8_t *disc_id, uint8_t *key, unsign
BD_DEBUG(DBG_FILE, "Error reading from %s\n", file);
}
free(key_str);
X_FREE(key_str);
fclose(fp);
......@@ -516,6 +523,9 @@ int cache_get(const char *name, uint32_t *version, uint32_t *len, void *buf)
int cache_remove(const char *name)
{
char *file = _cache_file(name);
if (!file) {
return 0;
}
int result = !remove(file);
if (!result) {
BD_DEBUG(DBG_FILE, "Error removing %s\n", file);
......
......@@ -391,6 +391,9 @@ static AACS_FILE_H *_file_open(AACS *aacs, const char *file)
}
f_name = str_printf("%s" DIR_SEP "%s", aacs->path, file);
if (!f_name) {
return NULL;
}
fp = file_open(f_name, "rb");
X_FREE(f_name);
......
......@@ -323,6 +323,12 @@ static gcry_error_t _aacs_sexp_key(gcry_sexp_t *p_sexp_key,
mpi_d ? "(d %m)" : ""
);
if (!strfmt) {
BD_DEBUG(DBG_AACS | DBG_CRIT, "out of memory\n");
err = GPG_ERR_ENOMEM;
goto error;
}
/* Now build the S-expression */
GCRY_VERIFY("gcry_sexp_build",
gcry_sexp_build(p_sexp_key, NULL, strfmt, mpi_d));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment