I was using svn and msys tools. I've moved to git. Hope this one will be more usefull. Short description:
BUG: Stack corruption when reading Intel Hex image file whith more the 128 sections - Franck -----Message d'origine----- De : David Brownell [mailto:davi...@pacbell.net] Envoyé : mardi 27 octobre 2009 19:42 À : openocd-development@lists.berlios.de Cc : Franck HERESON Objet : Re: [Openocd-development] stack corruption loading IHex On Tuesday 27 October 2009, Franck HERESON wrote: > > I've found a stack corruption loading an Hex file. > The Hex parser uses a fixed number of sections. > If the number of sections in the file is greater the ligne buffer get > corrupted and an CHECKSUM ERROR is detected which is very confusing. The > patch below prints a more correct message. To read my file ( > Primer2_Circle_Factory.hex) i had also to increase IMAGE_MAX_SECTIONS (491 > sections in the file). Your patch arrived in mangled form... it's indented much more than that in current code, and also "quoted-printable" encoding doesn't play nicely with many patch tools. Can you make sure it applies against the current git version (you seem to have sent a patch against some old SVN snapshot), and resend without the mangling? Plus you should probably also just increase that constant to 512 in your patch. - Dave
diff --git a/src/target/image.c b/src/target/image.c index d51e874..f9a020b 100644 --- a/src/target/image.c +++ b/src/target/image.c @@ -8,6 +8,9 @@ * Copyright (C) 2008 by Spencer Oliver * * s...@spen-soft.co.uk * * * + * Copyright (C) 2009 by Franck Hereson * + * franck.here...@secad.fr * + * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * @@ -196,6 +199,12 @@ static int image_ihex_buffer_complete(image_t *image) if (section[image->num_sections].size != 0) { image->num_sections++; + if( image->num_sections >= IMAGE_MAX_SECTIONS) + { + /* too much sections */ + LOG_ERROR("Too much sections found in IHEX file"); + return ERROR_IMAGE_FORMAT_ERROR; + } section[image->num_sections].size = 0x0; section[image->num_sections].flags = 0; section[image->num_sections].private = &ihex->buffer[cooked_bytes]; @@ -252,6 +261,12 @@ static int image_ihex_buffer_complete(image_t *image) if (section[image->num_sections].size != 0) { image->num_sections++; + if( image->num_sections >= IMAGE_MAX_SECTIONS) + { + /* too much sections */ + LOG_ERROR("Too much sections found in IHEX file"); + return ERROR_IMAGE_FORMAT_ERROR; + } section[image->num_sections].size = 0x0; section[image->num_sections].flags = 0; section[image->num_sections].private = &ihex->buffer[cooked_bytes]; @@ -292,6 +307,12 @@ static int image_ihex_buffer_complete(image_t *image) if (section[image->num_sections].size != 0) { image->num_sections++; + if( image->num_sections >= IMAGE_MAX_SECTIONS) + { + /* too much sections */ + LOG_ERROR("Too much sections found in IHEX file"); + return ERROR_IMAGE_FORMAT_ERROR; + } section[image->num_sections].size = 0x0; section[image->num_sections].flags = 0; section[image->num_sections].private = &ihex->buffer[cooked_bytes]; diff --git a/src/target/image.h b/src/target/image.h index d90b544..551524e 100644 --- a/src/target/image.h +++ b/src/target/image.h @@ -33,7 +33,7 @@ #endif #define IMAGE_MAX_ERROR_STRING (256) -#define IMAGE_MAX_SECTIONS (128) +#define IMAGE_MAX_SECTIONS (512) #define IMAGE_MEMORY_CACHE_SIZE (2048)
_______________________________________________ Openocd-development mailing list Openocd-development@lists.berlios.de https://lists.berlios.de/mailman/listinfo/openocd-development