summaryrefslogtreecommitdiffstats
path: root/lib/gui
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2012-12-02 11:38:49 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2012-12-03 11:23:25 +0100
commit5e742637623af0b1ea365b4c8ffda566a0ee3a2b (patch)
tree2e318879a6d386e5cd29639932f9498f6ac6c8b8 /lib/gui
parent3207dc4608dd1afa46fcdcc0b9eb7c3a3fe22882 (diff)
downloadbarebox-5e742637623af0b1ea365b4c8ffda566a0ee3a2b.tar.gz
barebox-5e742637623af0b1ea365b4c8ffda566a0ee3a2b.tar.xz
filetype: Pass bufsize
Pass the buffer size to the file detection code. This makes sure we do not read past the buffer. This is especially useful for ext filesystem detection as the magic is at byte offset 1080. Also introduce a FILE_TYPE_SAFE_BUFSIZE define which is set to the minimum bufsize the detection code needs to detect all known filetypes. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'lib/gui')
-rw-r--r--lib/gui/image_renderer.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/gui/image_renderer.c b/lib/gui/image_renderer.c
index 41dc43b3c7..78e5777cbd 100644
--- a/lib/gui/image_renderer.c
+++ b/lib/gui/image_renderer.c
@@ -13,10 +13,10 @@
static LIST_HEAD(image_renderers);
-static struct image_renderer *get_renderer(void* buf)
+static struct image_renderer *get_renderer(void* buf, size_t bufsize)
{
struct image_renderer *ir;
- enum filetype type = file_detect_type(buf);
+ enum filetype type = file_detect_type(buf, bufsize);
list_for_each_entry(ir, &image_renderers, list) {
if (ir->type == type)
@@ -40,7 +40,7 @@ struct image *image_renderer_open(const char* file)
return ERR_PTR(-ENOMEM);
}
- ir = get_renderer(data);
+ ir = get_renderer(data, size);
if (!ir) {
ret = -ENOENT;
goto out;