From fa3f6be5128071fe7e15563e727b5478c45a63b8 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Fri, 8 May 2015 14:23:03 -0700 Subject: [PATCH] client: fix bug when delete > 4GB file The function to delete a slot dir file (delete_project_owned_file()) called boinc_file_or_symlink_exists(), and returning success (with no message) if this return false. boinc_file_or_symlink_exists() incorrectly returned false for > 4GB file on Win, because it used stat(), which handles only 32 bit file size. Fix: remove the call to boinc_file_or_symlink_exists(); instead, always call DeleteFile(), and check for the ERROR_FILE_NOT_FOUND status. I'll fix the stat() problem later. --- client/sandbox.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/client/sandbox.cpp b/client/sandbox.cpp index 77d03def6f..7f11ecbae0 100644 --- a/client/sandbox.cpp +++ b/client/sandbox.cpp @@ -231,10 +231,16 @@ int set_to_project_group(const char*) { } #endif // ! _WIN32 +// delete a file. +// return success if we deleted it or it didn't exist in the first place +// static int delete_project_owned_file_aux(const char* path) { #ifdef _WIN32 if (DeleteFile(path)) return 0; int error = GetLastError(); + if (error == ERROR_FILE_NOT_FOUND) { + return 0; + } if (error == ERROR_ACCESS_DENIED) { SetFileAttributes(path, FILE_ATTRIBUTE_NORMAL); if (DeleteFile(path)) return 0; @@ -242,6 +248,9 @@ static int delete_project_owned_file_aux(const char* path) { return ERR_UNLINK; #else int retval = unlink(path); + if (retval == ENOENT) { + return 0; + } if (retval && g_use_sandbox && (errno == EACCES)) { // We may not have permission to read subdirectories created by projects return remove_project_owned_file_or_dir(path); @@ -258,9 +267,6 @@ static int delete_project_owned_file_aux(const char* path) { int delete_project_owned_file(const char* path, bool retry) { int retval = 0; - if (!boinc_file_or_symlink_exists(path)) { - return 0; - } retval = delete_project_owned_file_aux(path); if (retval && retry) { double start = dtime();