summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn-Mark Bell <jmb@netsurf-browser.org>2022-06-03 02:41:23 +0100
committerJohn-Mark Bell <jmb@netsurf-browser.org>2022-06-03 02:41:23 +0100
commite1d7928b3bdd97b24f1ff7d2b04ab7a2a65ef460 (patch)
treeabef926dffcf9b17b0319703bd8eae887b2af21f
parent617c6207bcd45daa8d66c35dbc4f1273686646f3 (diff)
downloadnetsurf-e1d7928b3bdd97b24f1ff7d2b04ab7a2a65ef460.tar.gz
netsurf-e1d7928b3bdd97b24f1ff7d2b04ab7a2a65ef460.tar.bz2
RISC OS: fix snprintf usage
When computing throbber sprite names, ensure the current frame is in range before using it. Similarly ensure the buffer size for the temporary URL bar sprite name is sized such that snprintf has space for the trailing NUL when formatting it to the output buffer.
-rw-r--r--frontends/riscos/gui/throbber.c4
-rw-r--r--frontends/riscos/gui/url_bar.c2
2 files changed, 4 insertions, 2 deletions
diff --git a/frontends/riscos/gui/throbber.c b/frontends/riscos/gui/throbber.c
index f3b79a68e..e3e4106cc 100644
--- a/frontends/riscos/gui/throbber.c
+++ b/frontends/riscos/gui/throbber.c
@@ -32,6 +32,7 @@
#include "oslib/wimp.h"
#include "utils/log.h"
+#include "utils/utils.h"
#include "riscos/gui.h"
#include "riscos/gui/throbber.h"
@@ -385,7 +386,8 @@ bool ro_gui_throbber_animate(struct throbber *throbber)
throbber->current_frame = 1;
snprintf(sprite_name, THROBBER_SPRITE_NAME_LENGTH,
- "throbber%i", throbber->current_frame);
+ "throbber%i",
+ min(max(throbber->current_frame, 0), 999));
ro_gui_set_icon_string(throbber->window, throbber->icon,
sprite_name, true);
diff --git a/frontends/riscos/gui/url_bar.c b/frontends/riscos/gui/url_bar.c
index ec21e9371..8802db731 100644
--- a/frontends/riscos/gui/url_bar.c
+++ b/frontends/riscos/gui/url_bar.c
@@ -1506,7 +1506,7 @@ ro_gui_url_bar_set_content_favicon(struct url_bar *url_bar,
struct gui_window *g)
{
int type = 0;
- char sprite[URLBAR_FAVICON_NAME_LENGTH];
+ char sprite[URLBAR_FAVICON_NAME_LENGTH-1];
struct hlcache_handle *h;
if (url_bar == NULL ||