Skip to content

Commit 40548c5

Browse files
authored
Merge pull request #4862 from computezrmle/patch-1
Increase msg_buf size
2 parents a5ca655 + 76ef51f commit 40548c5

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

client/sandbox.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ static int lookup_group(const char* name, gid_t& gid) {
185185
#endif
186186

187187
int remove_project_owned_file_or_dir(const char* path) {
188-
char cmd[1024];
188+
char cmd[5120];
189189

190190
if (g_use_sandbox) {
191191
snprintf(cmd, sizeof(cmd), "/bin/rm rm -fR \"%s\"", path);

lib/gui_rpc_client.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -413,14 +413,14 @@ int RPC::parse_reply() {
413413
// If present, it chdirs to that directory.
414414

415415
int read_gui_rpc_password(char* buf, string& msg) {
416-
char msg_buf[1024];
416+
char msg_buf[5120];
417417
FILE* f = fopen(GUI_RPC_PASSWD_FILE, "r");
418418
if (!f) {
419419
#if defined(__linux__)
420420
#define HELP_URL "https://boinc.berkeley.edu/gui_rpc.php"
421421
char path[MAXPATHLEN];
422422
if (errno == EACCES) {
423-
sprintf(msg_buf,
423+
snprintf(msg_buf, sizeof(msg_buf),
424424
"%s exists but can't be read. See %s",
425425
GUI_RPC_PASSWD_FILE, HELP_URL
426426
);
@@ -442,24 +442,24 @@ int read_gui_rpc_password(char* buf, string& msg) {
442442
fclose(g);
443443
if (p) {
444444
p += strlen("data_dir=");
445-
sprintf(path, "%s/%s", p, GUI_RPC_PASSWD_FILE);
445+
snprintf(path, sizeof(path), "%s/%s", p, GUI_RPC_PASSWD_FILE);
446446
f = fopen(path, "r");
447447
if (!f) {
448448
if (errno == EACCES) {
449-
sprintf(msg_buf,
449+
snprintf(msg_buf, sizeof(msg_buf),
450450
"%s exists but can't be read. See %s",
451451
path, HELP_URL
452452
);
453453
} else {
454-
sprintf(msg_buf, "%s not found. See %s",
454+
snprintf(msg_buf, sizeof(msg_buf), "%s not found. See %s",
455455
path, HELP_URL
456456
);
457457
}
458458
msg = msg_buf;
459459
return ERR_FOPEN;
460460
}
461461
} else {
462-
sprintf(msg_buf,
462+
snprintf(msg_buf, sizeof(msg_buf),
463463
"No data_dir= found in %s. See %s",
464464
LINUX_CONFIG_FILE, HELP_URL
465465
);
@@ -469,18 +469,18 @@ int read_gui_rpc_password(char* buf, string& msg) {
469469
} else {
470470
// no config file; look in default data dir
471471
//
472-
sprintf(path, "%s/%s", LINUX_DEFAULT_DATA_DIR, GUI_RPC_PASSWD_FILE);
472+
snprintf(path, sizeof(path), "%s/%s", LINUX_DEFAULT_DATA_DIR, GUI_RPC_PASSWD_FILE);
473473
f = fopen(path, "r");
474474
if (!f) {
475475
if (errno == EACCES) {
476-
sprintf(msg_buf,
476+
snprintf(msg_buf, sizeof(msg_buf),
477477
"%s exists but can't be read. See %s",
478478
path, HELP_URL
479479
);
480480
msg = msg_buf;
481481
return ERR_FOPEN;
482482
}
483-
sprintf(msg_buf, "%s not found. See %s",
483+
snprintf(msg_buf, sizeof(msg_buf), "%s not found. See %s",
484484
GUI_RPC_PASSWD_FILE, HELP_URL
485485
);
486486
msg = msg_buf;
@@ -491,12 +491,12 @@ int read_gui_rpc_password(char* buf, string& msg) {
491491
// non-Linux
492492

493493
if (errno == EACCES) {
494-
sprintf(msg_buf,
494+
snprintf(msg_buf, sizeof(msg_buf),
495495
"%s exists but can't be read. Make sure your account is in the 'boinc_users' group",
496496
GUI_RPC_PASSWD_FILE
497497
);
498498
} else {
499-
sprintf(msg_buf, "%s not found. Try reinstalling BOINC.",
499+
snprintf(msg_buf, sizeof(msg_buf), "%s not found. Try reinstalling BOINC.",
500500
GUI_RPC_PASSWD_FILE
501501
);
502502
}

0 commit comments

Comments
 (0)