diff options
author | David Phillips <dbphillipsnz@gmail.com> | 2015-09-01 19:22:47 +1200 |
---|---|---|
committer | David Phillips <dbphillipsnz@gmail.com> | 2015-09-01 19:22:47 +1200 |
commit | 841445fb7a482b9c1ed9eca896d308afab4316d8 (patch) | |
tree | 040506ac1a752aa85e61a542f736e5c6ea7305ca | |
parent | dec1efba06aeadcd9a4f13e8591f2efa016a24a0 (diff) | |
download | paramano-841445fb7a482b9c1ed9eca896d308afab4316d8.tar.xz |
Various buffer overflow fixes
-rw-r--r-- | bat_tray.c | 1 | ||||
-rw-r--r-- | tray.c | 8 |
2 files changed, 5 insertions, 4 deletions
@@ -144,6 +144,7 @@ static void update_tooltip_cache() break; } strncpy(tooltip_text, msg, sizeof(tooltip_text)); + tooltip_text[sizeof(tooltip_text)-1] = '\0'; } @@ -157,10 +157,10 @@ static gboolean show_tooltip(GtkStatusIcon* status_icon, gint x, gint y, gboolea **********************************************************************/ static void update_tooltip_cache() { - char msg[1024], label[1024]; + char msg[10240], label[1024]; char current_governor[20]; // TO DO unsigned int i = 0; - int offset = 0; + unsigned int offset = 0; memset(current_governor, '\0', sizeof(current_governor) ); @@ -171,11 +171,11 @@ static void update_tooltip_cache() for(i = 0; i < gc_number(); i++) { gf_get_frequency_label(label, sizeof(label), gf_current(i)); - offset += snprintf(msg+offset, sizeof(msg), _("CPU%d: %s%s"), i, label, i == gc_number()-1 ? "" : "\n"); + offset += snprintf(msg+offset, sizeof(msg)-offset, _("CPU%d: %s%s"), i, label, i == gc_number()-1 ? "" : "\n"); } strncpy(tooltip_text, msg, sizeof(tooltip_text)); - tooltip_text[sizeof(tooltip_text)] = '\0'; + tooltip_text[sizeof(tooltip_text)-1] = '\0'; } |