diff options
author | unknown <monty@narttu.mysql.fi> | 2003-03-10 11:22:37 +0200 |
---|---|---|
committer | unknown <monty@narttu.mysql.fi> | 2003-03-10 11:22:37 +0200 |
commit | 68ae365395c78eba74b4db66fb0989e76d221d0d (patch) | |
tree | caaf93f4311641760c5a58ab8099d7eab15c0d79 /mysys/my_copy.c | |
parent | 374ea106f5098e4a6ee79f217bf799d181d20a25 (diff) | |
download | mariadb-git-68ae365395c78eba74b4db66fb0989e76d221d0d.tar.gz |
Don't allow BACKUP TABLE to overwrite files
Fixed memory leak when replication restarts in debug mode
include/my_sys.h:
Added option to not overwrite files to my_copy()
mysql-test/mysql-test-run.sh:
Fixed --ddd option
Fixed that mysqld is restarted if there is a testname-master.sh file
mysql-test/r/backup.result:
Update for security fix in BACKUP TABLE
mysql-test/t/backup.test:
Update for security fix in BACKUP TABLE
mysys/my_copy.c:
Added option to not overwrite files to my_copy()
sql/ha_myisam.cc:
Don't allow BACKUP TABLE to overwrite files
sql/slave.cc:
Fixed problem with --debug output from 'handle_slave'
Fixed memory leak when replication restarts in debug mode
Diffstat (limited to 'mysys/my_copy.c')
-rw-r--r-- | mysys/my_copy.c | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/mysys/my_copy.c b/mysys/my_copy.c index 9b02d84d063..5bc4d1d51fa 100644 --- a/mysys/my_copy.c +++ b/mysys/my_copy.c @@ -32,17 +32,29 @@ struct utimbuf { #endif - /* - Ordinary ownership and accesstimes are copied from 'from-file' - if MyFlags & MY_HOLD_ORIGINAL_MODES is set and to-file exists then - the modes of to-file isn't changed - Dont set MY_FNABP or MY_NABP bits on when calling this function ! - */ +/* + int my_copy(const char *from, const char *to, myf MyFlags) + + NOTES + Ordinary ownership and accesstimes are copied from 'from-file' + If MyFlags & MY_HOLD_ORIGINAL_MODES is set and to-file exists then + the modes of to-file isn't changed + If MyFlags & MY_DONT_OVERWRITE_FILE is set, we will give an error + if the file existed. + + WARNING + Don't set MY_FNABP or MY_NABP bits on when calling this function ! + + RETURN + 0 ok + # Error + +*/ int my_copy(const char *from, const char *to, myf MyFlags) { uint Count; - int new_file_stat; + int new_file_stat, create_flag; File from_file,to_file; char buff[IO_SIZE]; struct stat stat_buff,new_stat_buff; @@ -63,8 +75,10 @@ int my_copy(const char *from, const char *to, myf MyFlags) } if (MyFlags & MY_HOLD_ORIGINAL_MODES && !new_file_stat) stat_buff=new_stat_buff; + create_flag= (MyFlags & MY_DONT_OVERWRITE_FILE) ? O_EXCL : O_TRUNC; + if ((to_file= my_create(to,(int) stat_buff.st_mode, - O_WRONLY | O_TRUNC | O_BINARY | O_SHARE, + O_WRONLY | create_flag | O_BINARY | O_SHARE, MyFlags)) < 0) goto err; |