summaryrefslogtreecommitdiff
path: root/apps/plugins/pictureflow
diff options
context:
space:
mode:
authorAidan MacDonald <amachronic@protonmail.com>2022-05-07 15:52:26 +0100
committerAidan MacDonald <amachronic@protonmail.com>2022-05-07 15:52:26 +0100
commitf661dc596e4c1b7d2d6479afbf4cb4690d6d3a7b (patch)
tree19879cd83828e1831a444bb6fd0742642ef21e1b /apps/plugins/pictureflow
parent2c4480979f1b0374414b4e49957f1772bd103b79 (diff)
downloadrockbox-f661dc596e4c1b7d2d6479afbf4cb4690d6d3a7b.tar.gz
rockbox-f661dc596e4c1b7d2d6479afbf4cb4690d6d3a7b.zip
pictureflow: fix bug in calculation of album art buf size
I intended to check for enough space in buffer but this isn't really doing it and it is making aa_bufsz slightly too big so it's a possible buffer overflow. Restore the old ALIGN_DOWN(..., 4) rounding in case it's important, if not, then no harm done. Change-Id: I904f255ac79a77d5328b44667502ceae8308e659
Diffstat (limited to 'apps/plugins/pictureflow')
-rw-r--r--apps/plugins/pictureflow/pictureflow.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/apps/plugins/pictureflow/pictureflow.c b/apps/plugins/pictureflow/pictureflow.c
index 83d4bb5a59..b2d170329e 100644
--- a/apps/plugins/pictureflow/pictureflow.c
+++ b/apps/plugins/pictureflow/pictureflow.c
@@ -4303,7 +4303,7 @@ static int pictureflow_main(const char* selected_file)
4303 4303
4304 number_of_slides = pf_idx.album_ct; 4304 number_of_slides = pf_idx.album_ct;
4305 4305
4306 size_t aa_bufsz = pf_idx.buf_sz / 4 + sizeof(long) - 1; 4306 size_t aa_bufsz = ALIGN_DOWN(pf_idx.buf_sz / 4, sizeof(long));
4307 if (aa_bufsz < DISPLAY_WIDTH * DISPLAY_HEIGHT * sizeof(pix_t)) 4307 if (aa_bufsz < DISPLAY_WIDTH * DISPLAY_HEIGHT * sizeof(pix_t))
4308 { 4308 {
4309 error_wait("Not enough memory for album art cache"); 4309 error_wait("Not enough memory for album art cache");
@@ -4313,6 +4313,7 @@ static int pictureflow_main(const char* selected_file)
4313 ALIGN_BUFFER(pf_idx.buf, pf_idx.buf_sz, sizeof(long)); 4313 ALIGN_BUFFER(pf_idx.buf, pf_idx.buf_sz, sizeof(long));
4314 aa_cache.buf = (char*) pf_idx.buf; 4314 aa_cache.buf = (char*) pf_idx.buf;
4315 aa_cache.buf_sz = aa_bufsz; 4315 aa_cache.buf_sz = aa_bufsz;
4316
4316 pf_idx.buf += aa_bufsz; 4317 pf_idx.buf += aa_bufsz;
4317 pf_idx.buf_sz -= aa_bufsz; 4318 pf_idx.buf_sz -= aa_bufsz;
4318 4319