summaryrefslogtreecommitdiff
path: root/apps/plugin.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugin.c')
-rw-r--r--apps/plugin.c8
1 files changed, 4 insertions, 4 deletions
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) {