Revisited Debian patch 'more_maxpathlen.patch'

Joint work by Steffen, Gianfranco and Yixuan since August 2012
https://salsa.debian.org/pkg-boinc-team/boinc/commits/master/debian/patches/more_maxpathlen.patch
This commit is contained in:
Steffen Moeller 2019-08-29 15:09:44 +02:00
parent 93f4dde515
commit ebb85ac6c3
2 changed files with 8 additions and 9 deletions

View File

@ -38,9 +38,9 @@
#ifdef __EMX__ #ifdef __EMX__
static key_t get_shmem_name(const char* prog_name) { static key_t get_shmem_name(const char* prog_name) {
char cwd[MAXPATHLEN], path[MAXPATHLEN]; char cwd[MAXPATHLEN+1], path[MAXPATHLEN+1];
boinc_getcwd(cwd); boinc_getcwd(cwd);
sprintf(path, "%s/init_data.xml", cwd); snprintf(path, sizeof(path), "%s/init_data.xml", cwd);
return ftok(path, 2); return ftok(path, 2);
} }
#else #else
@ -50,14 +50,14 @@ static void get_shmem_name(const char* prog_name, char* shmem_name) {
APP_INIT_DATA aid; APP_INIT_DATA aid;
int retval = boinc_get_init_data(aid); int retval = boinc_get_init_data(aid);
if (retval) aid.slot = 0; if (retval) aid.slot = 0;
sprintf(shmem_name, "boinc_%s_%d", prog_name, aid.slot); snprintf(shmem_name, MAXPATHLEN+1, "boinc_%s_%d", prog_name, aid.slot);
} }
#endif #endif
void* boinc_graphics_make_shmem(const char* prog_name, int size) { void* boinc_graphics_make_shmem(const char* prog_name, int size) {
#ifdef _WIN32 #ifdef _WIN32
HANDLE shmem_handle; HANDLE shmem_handle;
char shmem_name[MAXPATHLEN]; char shmem_name[MAXPATHLEN+1];
void* p; void* p;
get_shmem_name(prog_name, shmem_name); get_shmem_name(prog_name, shmem_name);
shmem_handle = create_shmem(shmem_name, size, &p); shmem_handle = create_shmem(shmem_name, size, &p);
@ -70,7 +70,7 @@ void* boinc_graphics_make_shmem(const char* prog_name, int size) {
int retval = create_shmem(key, size, 0, &p); int retval = create_shmem(key, size, 0, &p);
#else #else
// V6 Unix/Linux/Mac applications always use mmap() shared memory for graphics communication // V6 Unix/Linux/Mac applications always use mmap() shared memory for graphics communication
char shmem_name[MAXPATHLEN]; char shmem_name[MAXPATHLEN+1];
get_shmem_name(prog_name, shmem_name); get_shmem_name(prog_name, shmem_name);
int retval = create_shmem_mmap(shmem_name, size, &p); int retval = create_shmem_mmap(shmem_name, size, &p);
// make sure user/group RW permissions are set, but not other. // make sure user/group RW permissions are set, but not other.
@ -85,7 +85,7 @@ void* boinc_graphics_make_shmem(const char* prog_name, int size) {
#ifdef _WIN32 #ifdef _WIN32
void* boinc_graphics_get_shmem(const char* prog_name) { void* boinc_graphics_get_shmem(const char* prog_name) {
HANDLE shmem_handle; HANDLE shmem_handle;
char shmem_name[MAXPATHLEN]; char shmem_name[MAXPATHLEN+1];
void* p; void* p;
get_shmem_name(prog_name, shmem_name); get_shmem_name(prog_name, shmem_name);
shmem_handle = attach_shmem(shmem_name, &p); shmem_handle = attach_shmem(shmem_name, &p);
@ -103,7 +103,7 @@ void* boinc_graphics_get_shmem(const char* prog_name) {
retval = attach_shmem(key, &p); retval = attach_shmem(key, &p);
#else #else
// V6 Unix/Linux/Mac applications always use mmap() shared memory for graphics communication // V6 Unix/Linux/Mac applications always use mmap() shared memory for graphics communication
char shmem_name[MAXPATHLEN]; char shmem_name[MAXPATHLEN+1];
get_shmem_name(prog_name, shmem_name); get_shmem_name(prog_name, shmem_name);
retval = attach_shmem_mmap(shmem_name, &p); retval = attach_shmem_mmap(shmem_name, &p);
#endif #endif

View File

@ -598,9 +598,8 @@ int boinc_copy(const char* orig, const char* newf) {
} }
return 0; return 0;
#elif defined(__EMX__) #elif defined(__EMX__)
char cmd[2*MAXPATHLEN]; char cmd[2*MAXPATHLEN+4+2+4+1]; // 2 blanks, 4 '"'s, 1 terminating 0
snprintf(cmd, sizeof(cmd), "copy \"%s\" \"%s\"", orig, newf); snprintf(cmd, sizeof(cmd), "copy \"%s\" \"%s\"", orig, newf);
cmd[sizeof(cmd)-1] = 0;
return system(cmd); return system(cmd);
#else #else
// POSIX requires that shells run from an application will use the // POSIX requires that shells run from an application will use the