Skip to content

Commit

Permalink
Fixed heap use after free issue.
Browse files Browse the repository at this point in the history
  • Loading branch information
rahim-kanji committed Feb 16, 2024
1 parent e53cd20 commit 3f7a90c
Showing 1 changed file with 18 additions and 14 deletions.
32 changes: 18 additions & 14 deletions lib/MySQL_Thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1809,16 +1809,18 @@ bool MySQL_Threads_Handler::set_variable(char *name, const char *value) { // thi
return false;
} else if (value[0] == '/') {
char *full_path = strdup(value);
char *eval_dirname = dirname(full_path);
DIR* eventlog_dir = opendir(eval_dirname);
free(full_path);
if (eventlog_dir) {
char* eval_dirname = dirname(full_path);
DIR* eventlog_dir = opendir(eval_dirname);
if (eventlog_dir) {
closedir(eventlog_dir);
free(variables.auditlog_filename);
variables.auditlog_filename=strdup(value);
return true;
} else {
variables.auditlog_filename = strdup(value);
free(full_path);
return true;
}
else {
proxy_error("%s is an invalid value for auditlog_filename path, the directory cannot be accessed\n", eval_dirname);
free(full_path);
return false;
}
} else {
Expand All @@ -1833,16 +1835,18 @@ bool MySQL_Threads_Handler::set_variable(char *name, const char *value) { // thi
return false;
} else if (value[0] == '/') {
char *full_path = strdup(value);
char *eval_dirname = dirname(full_path);
DIR* eventlog_dir = opendir(eval_dirname);
free(full_path);
if (eventlog_dir) {
char* eval_dirname = dirname(full_path);
DIR* eventlog_dir = opendir(eval_dirname);
if (eventlog_dir) {
closedir(eventlog_dir);
free(variables.eventslog_filename);
variables.eventslog_filename=strdup(value);
return true;
} else {
variables.eventslog_filename = strdup(value);
free(full_path);
return true;
}
else {
proxy_error("%s is an invalid value for eventslog_filename path, the directory cannot be accessed\n", eval_dirname);
free(full_path);
return false;
}
} else {
Expand Down

0 comments on commit 3f7a90c

Please sign in to comment.