From 995514ae7dc200ba16cd8e083c99e2929af3c440 Mon Sep 17 00:00:00 2001 From: jylam Date: Fri, 24 Oct 2008 12:33:13 +0000 Subject: [PATCH] * Added bound-checking to file extension detection git-svn-id: file:///srv/caca.zoy.org/var/lib/svn/libpipi/trunk@3085 92316355-f0b4-4df1-b90c-862c8a59935f --- pipi/codec/modular.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pipi/codec/modular.c b/pipi/codec/modular.c index 1a7d55d..181ba9e 100644 --- a/pipi/codec/modular.c +++ b/pipi/codec/modular.c @@ -27,8 +27,9 @@ pipi_image_t *pipi_load_modular(const char *name) int pipi_save_modular(pipi_image_t *img, const char *name) { - if(!strncasecmp(&name[strlen(name) - 3], "jpg", 3) || - !strncasecmp(&name[strlen(name) - 4], "jpeg", 4) ) - return pipi_save_jpeg(img, name); + if(strlen(name) >= 4) + if(!strncasecmp(&name[strlen(name) - 3], "jpg", 3) || + !strncasecmp(&name[strlen(name) - 4], "jpeg", 4) ) + return pipi_save_jpeg(img, name); return -1; }