summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Arnold <amiconn@rockbox.org>2006-01-18 08:34:32 +0000
committerJens Arnold <amiconn@rockbox.org>2006-01-18 08:34:32 +0000
commita8c408c6a3049dc49e27f39008dff0001bf581bc (patch)
tree44762072cecd0143b2b47a5ee1d35db85a3c543a
parent22ffc9bf0337876157ce2f6ed2594dc81f979dba (diff)
downloadrockbox-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
-rw-r--r--apps/codecs.c6
-rw-r--r--apps/plugin.c8
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) {