diff options
author | Jens Arnold <amiconn@rockbox.org> | 2006-01-18 08:34:32 +0000 |
---|---|---|
committer | Jens Arnold <amiconn@rockbox.org> | 2006-01-18 08:34:32 +0000 |
commit | a8c408c6a3049dc49e27f39008dff0001bf581bc (patch) | |
tree | 44762072cecd0143b2b47a5ee1d35db85a3c543a /apps/plugin.c | |
parent | 22ffc9bf0337876157ce2f6ed2594dc81f979dba (diff) | |
download | rockbox-a8c408c6a3049dc49e27f39008dff0001bf581bc.tar.gz rockbox-a8c408c6a3049dc49e27f39008dff0001bf581bc.zip |
More consistent error checking.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@8364 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugin.c')
-rw-r--r-- | apps/plugin.c | 8 |
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) { |