public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Eric Sandeen <sandeen@sandeen.net>
To: Christoph Hellwig <hch@infradead.org>
Cc: xfs mailing list <xfs@oss.sgi.com>
Subject: Re: [PATCH] xfstests: fix buffer overflow in lstat64.c
Date: Wed, 12 Nov 2008 07:34:32 -0600	[thread overview]
Message-ID: <491ADB68.9010502@sandeen.net> (raw)
In-Reply-To: <20081112095702.GA2496@infradead.org>

Christoph Hellwig wrote:
> On Mon, Nov 03, 2008 at 04:26:07PM -0600, Eric Sandeen wrote:
>> lstat64.c was putting an 11-byte string into a 10-byte buffer.
> 
> What about somthing like this instead?

That's too easy! :)

Sure, that makes good sense.

-Eric

> 
> Index: xfs-cmds/xfstests/src/lstat64.c
> ===================================================================
> --- xfs-cmds.orig/xfstests/src/lstat64.c	2008-11-12 10:55:16.000000000 +0100
> +++ xfs-cmds/xfstests/src/lstat64.c	2008-11-12 10:55:50.000000000 +0100
> @@ -57,7 +57,6 @@ int
>  main(int argc, char **argv)
>  {
>  	struct stat64	sbuf;
> -	char		mode[10];
>  	int		i, c;
>  	int		terse_flag = 0;
>  
> @@ -78,6 +77,7 @@ main(int argc, char **argv)
>  	time(&timebuf);
>  
>  	for (i = optind; i < argc; i++) {
> +		char *mode = "----------";
>  
>  		if( lstat64(argv[i], &sbuf) < 0) {
>  			perror(argv[i]);
> @@ -92,7 +92,6 @@ main(int argc, char **argv)
>  			printf("  Size: %-10llu", (unsigned long long)sbuf.st_size);
>  		}
>  
> -		strcpy(mode,"----------");
>  		if (sbuf.st_mode & (S_IEXEC>>6))
>  			mode[9] = 'x';
>  		if (sbuf.st_mode & (S_IWRITE>>6))
> 

      reply	other threads:[~2008-11-12 13:34 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-11-03 22:26 [PATCH] xfstests: fix buffer overflow in lstat64.c Eric Sandeen
2008-11-12  9:57 ` Christoph Hellwig
2008-11-12 13:34   ` Eric Sandeen [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=491ADB68.9010502@sandeen.net \
    --to=sandeen@sandeen.net \
    --cc=hch@infradead.org \
    --cc=xfs@oss.sgi.com \
    /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