diff --git a/api/boinc_api.C b/api/boinc_api.C
index 9f7c0843e2..a37ee2e236 100644
--- a/api/boinc_api.C
+++ b/api/boinc_api.C
@@ -248,9 +248,12 @@ double boinc_worker_thread_cpu_time() {
// communicate to the core client (via shared mem)
// the current CPU time and fraction done
+// NOTE: various bugs could cause some of these FP numbers to be enormous,
+// possibly overflowing the buffer.
+// So use strlcat() instead of strcat()
//
static bool update_app_progress(double cpu_t, double cp_cpu_t) {
- char msg_buf[MSG_CHANNEL_SIZE], buf[256];
+ char msg_buf[MSG_CHANNEL_SIZE], buf[8000];
if (standalone) return true;
@@ -260,29 +263,29 @@ static bool update_app_progress(double cpu_t, double cp_cpu_t) {
cpu_t, cp_cpu_t
);
if (want_network) {
- strcat(msg_buf, "1\n");
+ strlcat(msg_buf, "1\n", MSG_CHANNEL_SIZE);
}
if (fraction_done >= 0) {
double range = aid.fraction_done_end - aid.fraction_done_start;
double fdone = aid.fraction_done_start + fraction_done*range;
sprintf(buf, "%2.8f\n", fdone);
- strcat(msg_buf, buf);
+ strlcat(msg_buf, buf, MSG_CHANNEL_SIZE);
}
if (fpops_per_cpu_sec) {
sprintf(buf, "%f\n", fpops_per_cpu_sec);
- strcat(msg_buf, buf);
+ strlcat(msg_buf, buf, MSG_CHANNEL_SIZE);
}
if (fpops_cumulative) {
sprintf(buf, "%f\n", fpops_cumulative);
- strcat(msg_buf, buf);
+ strlcat(msg_buf, buf, MSG_CHANNEL_SIZE);
}
if (intops_per_cpu_sec) {
sprintf(buf, "%f\n", intops_per_cpu_sec);
- strcat(msg_buf, buf);
+ strlcat(msg_buf, buf, MSG_CHANNEL_SIZE);
}
if (intops_cumulative) {
sprintf(buf, "%f\n", intops_cumulative);
- strcat(msg_buf, buf);
+ strlcat(msg_buf, buf, MSG_CHANNEL_SIZE);
}
return app_client_shm->shm->app_status.send_msg(msg_buf);
}
diff --git a/checkin_notes b/checkin_notes
index 5ba78388e9..db45dd9e65 100644
--- a/checkin_notes
+++ b/checkin_notes
@@ -10201,3 +10201,14 @@ David 30 Oct 2007
bolt.php
bolt_course_sample.php
bolt_sched.php
+
+David 30 Oct 2007
+ - API: when creating message strings for CPU time etc.,
+ use strlcat() instead of strcat().
+ Einstein@home has seen some SEGVs in this function.
+ I suspect that it's getting 1e304-type values
+ (why? possible bugs in getrusage-related code, still)
+ and that these cause long strings that overflow the message buffer.
+
+ api/
+ boinc_api.C