Skip to content

Commit

Permalink
Fix memory overflow
Browse files Browse the repository at this point in the history
Co-authored-by: MecryWork
  • Loading branch information
lk-me authored Aug 12, 2021
1 parent 60b8851 commit 33bbd21
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ static char *CacheSystem_calc_dir(const char *url)
fprintf(stderr, "CacheSystem_calc_dir(): mkdir(): %s\n",
strerror(errno));
}
free(fn);
free(cache_dir_root);
curl_free(escaped_url);
curl_easy_cleanup(c);
Expand Down Expand Up @@ -115,10 +116,9 @@ void CacheSystem_init(const char *path, int url_supplied)
"CacheSystem_init(): opendir(): %s\n", strerror(errno));
exit_failure();
}

closedir(dir);
META_DIR = path_append(path, "meta/");
DATA_DIR = path_append(path, "data/");

/* Check if directories exist, if not, create them */
if (mkdir(META_DIR, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH)
&& (errno != EEXIST)) {
Expand Down Expand Up @@ -463,6 +463,8 @@ int CacheDir_create(const char *dirn)
if (i && (errno != EEXIST)) {
fprintf(stderr, "CacheDir_create(): mkdir(): %s\n", strerror(errno));
}
free(datadirn);
free(metadirn);
return -i;
}

Expand Down
1 change: 1 addition & 0 deletions src/link.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ LinkTable *LinkSystem_init(const char *raw_url)
ROOT_LINK_TBL = sonic_LinkTable_new_id3(0, "0");
}
}
free(url);
return ROOT_LINK_TBL;
}

Expand Down
1 change: 1 addition & 0 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ void parse_config_file(char ***argv, int *argc)
}
}
}
free(full_path);
}

static int
Expand Down

0 comments on commit 33bbd21

Please sign in to comment.