From: Wolfgang Denk Date: Sat, 13 Dec 2008 23:48:23 +0100 Subject: [U-Boot] fat.c:707: warning: array subscript is above array bounds In-Reply-To: <20081213222225.GN15295@game.jcrosoft.org> References: <20081213221301.C91B0832E8A1@gemini.denx.de> <20081213222225.GN15295@game.jcrosoft.org> Message-ID: <20081213224823.57135832E8A1@gemini.denx.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Dear Jean-Christophe PLAGNIOL-VILLARD, In message <20081213222225.GN15295@game.jcrosoft.org> you wrote: > > > 705 /* Terminate fs_type string. Writing past the end of vistart > > 706 is ok - it's just the buffer. */ > > 707 vistart->fs_type[8] = '\0'; > > why not do something like this > > *(vistart + sizeof(volume_info)) = '\0'; Because that would be terribly wrong - sizeof(volume_info) is > 23 (probably 24), and vistart is a pointer volume_info, so you would probably write some 500+ bytes beyond the end of the buffer. Best regards, Wolfgang Denk -- DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de People seldom know what they want until you give them what they ask for.