diff options
author | Hisham Muhammad <hisham@gobolinux.org> | 2017-07-27 16:07:50 -0300 |
---|---|---|
committer | Hisham Muhammad <hisham@gobolinux.org> | 2017-07-27 16:07:50 -0300 |
commit | 09e241fb1271021e3615512debd3136891547562 (patch) | |
tree | 8245b6084607a34185cfa7d3d45f5228937020f1 /TasksMeter.c | |
parent | 3975e9ce5cba0e3972b2ddab28c198e000441501 (diff) |
Security review: check results of snprintf.
Calls marked with xSnprintf shouldn't fail.
Abort program cleanly if any of them does.
Diffstat (limited to 'TasksMeter.c')
-rw-r--r-- | TasksMeter.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/TasksMeter.c b/TasksMeter.c index 3e695319..6a08d885 100644 --- a/TasksMeter.c +++ b/TasksMeter.c @@ -30,7 +30,7 @@ static void TasksMeter_updateValues(Meter* this, char* buffer, int len) { if (this->pl->settings->hideKernelThreads) { this->values[0] = 0; } - snprintf(buffer, len, "%d/%d", (int) this->values[3], (int) this->total); + xSnprintf(buffer, len, "%d/%d", (int) this->values[3], (int) this->total); } static void TasksMeter_display(Object* cast, RichString* out) { @@ -40,7 +40,7 @@ static void TasksMeter_display(Object* cast, RichString* out) { int processes = (int) this->values[2]; - snprintf(buffer, sizeof(buffer), "%d", processes); + xSnprintf(buffer, sizeof(buffer), "%d", processes); RichString_write(out, CRT_colors[METER_VALUE], buffer); int threadValueColor = CRT_colors[METER_VALUE]; int threadCaptionColor = CRT_colors[METER_TEXT]; @@ -50,18 +50,18 @@ static void TasksMeter_display(Object* cast, RichString* out) { } if (!settings->hideUserlandThreads) { RichString_append(out, CRT_colors[METER_TEXT], ", "); - snprintf(buffer, sizeof(buffer), "%d", (int)this->values[1]); + xSnprintf(buffer, sizeof(buffer), "%d", (int)this->values[1]); RichString_append(out, threadValueColor, buffer); RichString_append(out, threadCaptionColor, " thr"); } if (!settings->hideKernelThreads) { RichString_append(out, CRT_colors[METER_TEXT], ", "); - snprintf(buffer, sizeof(buffer), "%d", (int)this->values[0]); + xSnprintf(buffer, sizeof(buffer), "%d", (int)this->values[0]); RichString_append(out, threadValueColor, buffer); RichString_append(out, threadCaptionColor, " kthr"); } RichString_append(out, CRT_colors[METER_TEXT], "; "); - snprintf(buffer, sizeof(buffer), "%d", (int)this->values[3]); + xSnprintf(buffer, sizeof(buffer), "%d", (int)this->values[3]); RichString_append(out, CRT_colors[TASKS_RUNNING], buffer); RichString_append(out, CRT_colors[METER_TEXT], " running"); } |