From b412b9d172cdd82c418d6c3611b986787f5f26b9 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Sun, 2 Sep 2012 20:05:20 +0000 Subject: [PATCH] - client: fix bug that broke file signing with X.509 certificates. From matszpk. Fixes #1168. svn path=/trunk/boinc/; revision=26071 --- checkin_notes | 10 ++++++++++ client/cs_files.cpp | 6 +++--- lib/crypt.cpp | 4 ++-- lib/filesys.cpp | 18 +++++++++--------- lib/filesys.h | 4 ++-- 5 files changed, 26 insertions(+), 16 deletions(-) diff --git a/checkin_notes b/checkin_notes index 253a0f9c04..d3b8e1d70b 100644 --- a/checkin_notes +++ b/checkin_notes @@ -5841,3 +5841,13 @@ David 30 Aug 2012 sched_send.cpp tools/ tt_boinc + +David 2 Sept 2012 + - client: fix bug that broke file signing with X.509 certificates. + From matszpk. Fixes #1168. + + lib/ + filesys.cpp,h + crypt.cpp + client/ + cs_files.cpp diff --git a/client/cs_files.cpp b/client/cs_files.cpp index 9fab86b6f9..f05ec07b9a 100644 --- a/client/cs_files.cpp +++ b/client/cs_files.cpp @@ -90,12 +90,12 @@ int CLIENT_STATE::make_project_dirs() { // Is app signed by one of the Application Certifiers? // bool FILE_INFO::verify_file_certs() { - char file[256]; + char file[MAXPATHLEN]; bool retval = false; if (!is_dir(CERTIFICATE_DIRECTORY)) return false; DIRREF dir = dir_open(CERTIFICATE_DIRECTORY); - while (dir_scan(file, dir, sizeof(file))) { + while (!dir_scan(file, dir, sizeof(file))) { if (cert_verify_file(cert_sigs, file, CERTIFICATE_DIRECTORY)) { msg_printf(project, MSG_INFO, "Signature verified using certificate %s", file @@ -156,7 +156,7 @@ bool FILE_INFO::verify_file_certs() { int FILE_INFO::verify_file( bool verify_contents, bool show_errors, bool allow_async ) { - char cksum[64], pathname[256]; + char cksum[64], pathname[MAXPATHLEN]; bool verified; int retval; double size, local_nbytes; diff --git a/lib/crypt.cpp b/lib/crypt.cpp index 9c7d145c25..624841d1c0 100644 --- a/lib/crypt.cpp +++ b/lib/crypt.cpp @@ -602,8 +602,8 @@ char *check_validity( DIRREF dir = dir_open(certPath); - char file[256]; - while (dir_scan(file, dir, sizeof(file))) { + char file[MAXPATHLEN]; + while (!dir_scan(file, dir, sizeof(file))) { char fpath[MAXPATHLEN]; snprintf(fpath, sizeof(fpath), "%s/%s", certPath, file); // TODO : replace '128' diff --git a/lib/filesys.cpp b/lib/filesys.cpp index a4f4ff48c2..32179e464d 100644 --- a/lib/filesys.cpp +++ b/lib/filesys.cpp @@ -82,7 +82,7 @@ typedef BOOL (CALLBACK* FreeFn)(LPCSTR, PULARGE_INTEGER, PULARGE_INTEGER, PULARG using std::string; -char boinc_failed_file[256]; +char boinc_failed_file[MAXPATHLEN]; // routines for enumerating the entries in a directory @@ -206,7 +206,7 @@ void dir_close(DIRREF dirp) { } bool is_dir_empty(const char *p) { - char file[256]; + char file[MAXPATHLEN]; DIRREF dir = dir_open(p); if (!dir) return true; @@ -360,7 +360,7 @@ int boinc_truncate(const char* path, double size) { // remove everything from specified directory // int clean_out_dir(const char* dirpath) { - char filename[256], path[MAXPATHLEN]; + char filename[MAXPATHLEN], path[MAXPATHLEN]; int retval; DIRREF dirp; @@ -732,13 +732,13 @@ int FILE_LOCK::unlock(const char* filename) { void boinc_getcwd(char* path) { #ifdef _WIN32 - getcwd(path, 256); + getcwd(path, MAXPATHLEN); #else char* p #ifdef __GNUC__ __attribute__ ((unused)) #endif - = getcwd(path, 256); + = getcwd(path, MAXPATHLEN); #endif } @@ -754,8 +754,8 @@ void relative_to_absolute(const char* relname, char* path) { // #ifdef _WIN32 int get_filesystem_info(double &total_space, double &free_space, char*) { - char buf[256]; - boinc_getcwd(buf); + char cwd[MAXPATHLEN]; + boinc_getcwd(cwd); FreeFn pGetDiskFreeSpaceEx; pGetDiskFreeSpaceEx = (FreeFn)GetProcAddress( GetModuleHandleA("kernel32.dll"), "GetDiskFreeSpaceExA" @@ -765,7 +765,7 @@ int get_filesystem_info(double &total_space, double &free_space, char*) { ULARGE_INTEGER TotalNumberOfBytes; ULARGE_INTEGER FreeBytesAvailable; pGetDiskFreeSpaceEx( - buf, &FreeBytesAvailable, &TotalNumberOfBytes, + cwd, &FreeBytesAvailable, &TotalNumberOfBytes, &TotalNumberOfFreeBytes ); signed __int64 uMB; @@ -779,7 +779,7 @@ int get_filesystem_info(double &total_space, double &free_space, char*) { DWORD dwFreeClusters; DWORD dwTotalClusters; GetDiskFreeSpaceA( - buf, &dwSectPerClust, &dwBytesPerSect, &dwFreeClusters, + cwd, &dwSectPerClust, &dwBytesPerSect, &dwFreeClusters, &dwTotalClusters ); free_space = (double)dwFreeClusters * dwSectPerClust * dwBytesPerSect; diff --git a/lib/filesys.h b/lib/filesys.h index 8f1fd1f517..323f1a03f2 100644 --- a/lib/filesys.h +++ b/lib/filesys.h @@ -55,7 +55,7 @@ extern "C" { extern void boinc_getcwd(char*); extern void relative_to_absolute(const char* relname, char* path); extern int boinc_make_dirs(const char*, const char*); - extern char boinc_failed_file[256]; + extern char boinc_failed_file[MAXPATHLEN]; extern int is_file(const char* path); extern int is_dir(const char* path); extern int is_dir_follow_symlinks(const char* path); @@ -82,7 +82,7 @@ extern int get_filesystem_info(double& total, double& free, char* path=const_cas // #if defined(_WIN32) && !defined(__CYGWIN32__) typedef struct _DIR_DESC { - char path[256]; + char path[MAXPATHLEN]; bool first; void* handle; } DIR_DESC;