diff options
author | unknown <serg@serg.mylan> | 2004-05-04 14:36:23 +0200 |
---|---|---|
committer | unknown <serg@serg.mylan> | 2004-05-04 14:36:23 +0200 |
commit | 7e41bc959c70de89368bb5b1a487a1ace3c2a635 (patch) | |
tree | d483541e692b19b3b224dce7159dea2e3989c3fd /sql | |
parent | f543ca9149632b4ed2f922ffcc46b2ba880d14b9 (diff) | |
download | mariadb-git-7e41bc959c70de89368bb5b1a487a1ace3c2a635.tar.gz |
don't rely on readdir() returning . and .. first
Diffstat (limited to 'sql')
-rw-r--r-- | sql/sql_base.cc | 8 | ||||
-rw-r--r-- | sql/sql_db.cc | 7 |
2 files changed, 13 insertions, 2 deletions
diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 9f1caca55bc..6bf0b0bd2ba 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -2255,9 +2255,15 @@ static void mysql_rm_tmp_tables(void) ** Remove all SQLxxx tables from directory */ - for (idx=2 ; idx < (uint) dirp->number_off_files ; idx++) + for (idx=0 ; idx < (uint) dirp->number_off_files ; idx++) { file=dirp->dir_entry+idx; + + /* skiping . and .. */ + if (file->name[0] == '.' && (!file->name[1] || + (file->name[1] == '.' && !file->name[2]))) + continue; + if (!bcmp(file->name,tmp_file_prefix,tmp_file_prefix_length)) { sprintf(filePath,"%s%s",mysql_tmpdir,file->name); /* purecov: inspected */ diff --git a/sql/sql_db.cc b/sql/sql_db.cc index d91fdbaded0..7dd458a3b5d 100644 --- a/sql/sql_db.cc +++ b/sql/sql_db.cc @@ -237,7 +237,7 @@ static long mysql_rm_known_files(THD *thd, MY_DIR *dirp, const char *db, tot_list_next= &tot_list; - for (uint idx=2 ; + for (uint idx=0 ; idx < (uint) dirp->number_off_files && !thd->killed ; idx++) { @@ -245,6 +245,11 @@ static long mysql_rm_known_files(THD *thd, MY_DIR *dirp, const char *db, char *extension; DBUG_PRINT("info",("Examining: %s", file->name)); + /* skiping . and .. */ + if (file->name[0] == '.' && (!file->name[1] || + (file->name[1] == '.' && !file->name[2]))) + continue; + /* Check if file is a raid directory */ if ((isdigit(file->name[0]) || (file->name[0] >= 'a' && file->name[0] <= 'f')) && |