diff options
Diffstat (limited to 'apps')
-rw-r--r-- | apps/codecs.c | 6 | ||||
-rw-r--r-- | apps/plugin.c | 8 |
2 files changed, 7 insertions, 7 deletions
diff --git a/apps/codecs.c b/apps/codecs.c index d12b43642f..d8ad7146df 100644 --- a/apps/codecs.c +++ b/apps/codecs.c | |||
@@ -243,7 +243,8 @@ int codec_load_ram(char* codecptr, int size, void* ptr2, int bufwrap, | |||
243 | } | 243 | } |
244 | hdr = (struct codec_header *)codecbuf; | 244 | hdr = (struct codec_header *)codecbuf; |
245 | 245 | ||
246 | if (hdr->magic != CODEC_MAGIC | 246 | if (size <= (signed)sizeof(struct codec_header) |
247 | || hdr->magic != CODEC_MAGIC | ||
247 | || hdr->target_id != TARGET_ID | 248 | || hdr->target_id != TARGET_ID |
248 | || hdr->load_addr != codecbuf | 249 | || hdr->load_addr != codecbuf |
249 | || hdr->end_addr > codecbuf + CODEC_SIZE) { | 250 | || hdr->end_addr > codecbuf + CODEC_SIZE) { |
@@ -258,8 +259,7 @@ int codec_load_ram(char* codecptr, int size, void* ptr2, int bufwrap, | |||
258 | 259 | ||
259 | if (hdr == NULL | 260 | if (hdr == NULL |
260 | || hdr->magic != CODEC_MAGIC | 261 | || hdr->magic != CODEC_MAGIC |
261 | || hdr->target_id != TARGET_ID | 262 | || hdr->target_id != TARGET_ID) { |
262 | || hdr->entry_point == NULL) { | ||
263 | sim_codec_close(pd); | 263 | sim_codec_close(pd); |
264 | return CODEC_ERROR; | 264 | return CODEC_ERROR; |
265 | } | 265 | } |
diff --git a/apps/plugin.c b/apps/plugin.c index a6b9703f1a..44eb0dc04c 100644 --- a/apps/plugin.c +++ b/apps/plugin.c | |||
@@ -399,8 +399,7 @@ int plugin_load(const char* plugin, void* parameter) | |||
399 | } | 399 | } |
400 | if (hdr == NULL | 400 | if (hdr == NULL |
401 | || hdr->magic != PLUGIN_MAGIC | 401 | || hdr->magic != PLUGIN_MAGIC |
402 | || hdr->target_id != TARGET_ID | 402 | || hdr->target_id != TARGET_ID) { |
403 | || hdr->entry_point == NULL) { | ||
404 | sim_plugin_close(fd); | 403 | sim_plugin_close(fd); |
405 | gui_syncsplash(HZ*2, true, str(LANG_PLUGIN_WRONG_MODEL)); | 404 | gui_syncsplash(HZ*2, true, str(LANG_PLUGIN_WRONG_MODEL)); |
406 | return -1; | 405 | return -1; |
@@ -423,13 +422,14 @@ int plugin_load(const char* plugin, void* parameter) | |||
423 | readsize = read(fd, pluginbuf, PLUGIN_BUFFER_SIZE); | 422 | readsize = read(fd, pluginbuf, PLUGIN_BUFFER_SIZE); |
424 | close(fd); | 423 | close(fd); |
425 | 424 | ||
426 | if (readsize <= (signed)sizeof(struct plugin_header)) { | 425 | if (readsize < 0) { |
427 | gui_syncsplash(HZ*2, true, str(LANG_READ_FAILED), plugin); | 426 | gui_syncsplash(HZ*2, true, str(LANG_READ_FAILED), plugin); |
428 | return -1; | 427 | return -1; |
429 | } | 428 | } |
430 | hdr = (struct plugin_header *)pluginbuf; | 429 | hdr = (struct plugin_header *)pluginbuf; |
431 | 430 | ||
432 | if (hdr->magic != PLUGIN_MAGIC | 431 | if ((unsigned)readsize <= sizeof(struct plugin_header) |
432 | || hdr->magic != PLUGIN_MAGIC | ||
433 | || hdr->target_id != TARGET_ID | 433 | || hdr->target_id != TARGET_ID |
434 | || hdr->load_addr != pluginbuf | 434 | || hdr->load_addr != pluginbuf |
435 | || hdr->end_addr > pluginbuf + PLUGIN_BUFFER_SIZE) { | 435 | || hdr->end_addr > pluginbuf + PLUGIN_BUFFER_SIZE) { |