From: Wolfgang Denk Date: Fri, 11 Feb 2011 20:21:15 +0100 Subject: [U-Boot] [PATCH] unzip: return uncompressed size in `filesize', and print it. In-Reply-To: <1297443439.965.1208.camel@petert> References: <1297431070-29533-1-git-send-email-wd@denx.de> <1297443439.965.1208.camel@petert> Message-ID: <20110211192115.6431A135593@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 Peter Tyser, In message <1297443439.965.1208.camel@petert> you wrote: > > > - return !!gunzip((void *) dst, dst_len, (void *) src, &src_len); > > + rc = gunzip((void *) dst, dst_len, (void *) src, &src_len); > > + > > + printf("Uncompressed size: %ld = 0x%lX\n", src_len, src_len); > > + sprintf(buf, "%lX", src_len); > > + setenv("filesize", buf); > > + > > + return !!rc; > > What about: > if (rc) > return rc; > > printf("Uncompressed size: %ld = 0x%lX\n", src_len, src_len); > sprintf(buf, "%lX", src_len); > setenv("filesize", buf); > > return 0; > > > This will prevent printing and setting of bogus values when an invalid > or overly large image is unzipped. Good point, will fix. Thanks! 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 HANDLE WITH EXTREME CARE: This Product Contains Minute Electrically Charged Particles Moving at Velocities in Excess of Five Hundred Million Miles Per Hour.