From mboxrd@z Thu Jan 1 00:00:00 1970 From: Albert ARIBAUD Date: Fri, 13 Dec 2013 10:00:00 +0100 Subject: [U-Boot] [PATCH v3 1/4] mkexynosspl: fix uninitialized buffer In-Reply-To: <1386608961-15503-1-git-send-email-albert.u.boot@aribaud.net> References: <1386608961-15503-1-git-send-email-albert.u.boot@aribaud.net> Message-ID: <20131213100000.41df0c9d@lilith> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de (adding Minkyu as the Samsung custodian) On Mon, 9 Dec 2013 18:09:18 +0100, Albert ARIBAUD wrote: > mkexynos reads its input file which might be smaller than ( typo: s/mkexynos/mkexynosspl/ -- wil fix when applying if thee is no other change to be made ) > its read buffer, but always writes the whole buffer out. > This does not affect the functionalyty of the output file, > but it makes its content unpredictable as the end of the > buffer is never initialized. Fix this by zeroing the buffer > before reading the input file. Minkyu: should the buffer be pre-filled with zeroes or should I use ones instead? Or maybe the output could be truncated to the size of the input? Amicalement, Albert. > Signed-off-by: Albert ARIBAUD > --- > Changes in v3: > - fixed mkexynosspl uninitialized buffer > > Changes in v2: None > > tools/mkexynosspl.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/tools/mkexynosspl.c b/tools/mkexynosspl.c > index ef685b7..8d605fa 100644 > --- a/tools/mkexynosspl.c > +++ b/tools/mkexynosspl.c > @@ -72,6 +72,8 @@ int main(int argc, char **argv) > > count = (len < CHECKSUM_OFFSET) ? len : CHECKSUM_OFFSET; > > + memset(buffer, 0, BUFSIZE); > + > if (read(ifd, buffer, count) != count) { > fprintf(stderr, "%s: Can't read %s: %s\n", > argv[0], argv[1], strerror(errno));