public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Jan Stancek <jstancek@redhat.com>
To: Helge Deller <deller@gmx.de>
Cc: ltp-list@lists.sourceforge.net
Subject: Re: [LTP] [PATCH] sendfile08 - initialize buf structure
Date: Wed, 6 Nov 2013 16:13:06 -0500 (EST)	[thread overview]
Message-ID: <1198475184.23113242.1383772386323.JavaMail.root@redhat.com> (raw)
In-Reply-To: <527A9B57.1000908@gmx.de>





----- Original Message -----
> From: "Helge Deller" <deller@gmx.de>
> To: ltp-list@lists.sourceforge.net
> Sent: Wednesday, 6 November, 2013 8:41:11 PM
> Subject: [LTP] [PATCH] sendfile08 - initialize buf structure
> 
> The sendfile08 testcase uses the sendfile() syscall
> to write the strings "hello" and "world" to a file descriptor
> and then reads them back in through another file descriptor.
> 
> The length of the strings written are determined by strlen(),
> so that in total 10 bytes are written.
> 
> When reading the strings back in, again 10 bytes are read, but
> the problem is, that those are read back into a *local* string
> buffer array (buf[]) which hasn't been initialized.
> 
> Afterwards,
>   strcmp(buf, "helloworld")
> is called to compare input and output.
> This strcmp() is wrong, because basically "helloworld\0"
> (with the trailing string zero terminator) is compared to
> "helloworld" (likely without a trailing zero in the buf[] array).
> 
> So, if buf[] hasn't been initialized, it's not guaranteed
> that the 10th byte in buf[10] equals to '\0'.
> 
> This problem was found on hppa64-linux-gnu architecture, most
> likely, because it's a stack-grows-up architecture.
> 
> Fix this buglet, by zero-initializing the buf[] array.
> Alternatively, strncmp() could be used instead of memcmp().
> 
> Signed-off-by: Helge Deller <deller@gmx.de>

Hi,

I pushed the strncmp() version.

Thanks,
Jan

> 
> ------------------------------------------------------------------------------
> November Webinars for C, C++, Fortran Developers
> Accelerate application performance with scalable programming models. Explore
> techniques for threading, error checking, porting, and tuning. Get the most
> from the latest Intel processors and coprocessors. See abstracts and register
> http://pubads.g.doubleclick.net/gampad/clk?id=60136231&iu=/4140/ostg.clktrk
> _______________________________________________
> Ltp-list mailing list
> Ltp-list@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/ltp-list
> 

------------------------------------------------------------------------------
November Webinars for C, C++, Fortran Developers
Accelerate application performance with scalable programming models. Explore
techniques for threading, error checking, porting, and tuning. Get the most 
from the latest Intel processors and coprocessors. See abstracts and register
http://pubads.g.doubleclick.net/gampad/clk?id=60136231&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

      reply	other threads:[~2013-11-06 21:13 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-06 19:41 [LTP] [PATCH] sendfile08 - initialize buf structure Helge Deller
2013-11-06 21:13 ` Jan Stancek [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1198475184.23113242.1383772386323.JavaMail.root@redhat.com \
    --to=jstancek@redhat.com \
    --cc=deller@gmx.de \
    --cc=ltp-list@lists.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox