public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Mark Tinguely <tinguely@sgi.com>
To: Eric Sandeen <sandeen@sandeen.net>
Cc: Eric Sandeen <sandeen@redhat.com>,
	Brian Foster <bfoster@redhat.com>, xfs-oss <xfs@oss.sgi.com>
Subject: Re: [PATCH 1/3] xfs_fsr: ensure the line we read from leftofffile is null terminated
Date: Mon, 09 Jun 2014 09:29:30 -0500	[thread overview]
Message-ID: <5395C4CA.6010206@sgi.com> (raw)
In-Reply-To: <5395BE32.3080204@sandeen.net>

On 06/09/14 09:01, Eric Sandeen wrote:
> On 6/9/14, 8:02 AM, Brian Foster wrote:
>> On Fri, Jun 06, 2014 at 04:03:10PM -0500, Eric Sandeen wrote:
>>> Ensure that the string we read from leftofffile is NULL
>>> terminated; the buffer gets passed to strchr(), so
>>> it's important that we ensure it ends with NULL.
>>>
>>> Signed-off-by: Eric Sandeen<sandeen@redhat.com>
>>> ---
>>>
>>> diff --git a/fsr/xfs_fsr.c b/fsr/xfs_fsr.c
>>> index 3818f02..94d235c 100644
>>> --- a/fsr/xfs_fsr.c
>>> +++ b/fsr/xfs_fsr.c
>>> @@ -554,6 +554,8 @@ fsrallfs(char *mtab, int howlong, char *leftofffile)
>>>   			fsrprintf(_("could not read %s, starting with %s\n"),
>>>   				leftofffile, *fs->dev);
>>>   		} else {
>>> +			/* Ensure the buffer we read is null terminated */
>>> +			buf[SMBUFSZ-1] = '\0';
>>
>> Maybe just initialize the buffer..?
>
> and then read no more than SMBUFSZ-1... I dunno, 6 one way, half a dozen
> the other?

I like my bike shed pained red with white and blue swirlies. :)

The strings should be NULL terminated for the string ops. It makes more 
sense to NULL one byte than 1024. If the full SMBUFSZ bytes are desired, 
then bump the array for the NULL byte.

--Mark.

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

  reply	other threads:[~2014-06-09 14:29 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-06 20:57 [PATCH 0/3] xfs_fsr robustification Eric Sandeen
2014-06-06 21:03 ` [PATCH 1/3] xfs_fsr: ensure the line we read from leftofffile is null terminated Eric Sandeen
2014-06-09 13:02   ` Brian Foster
2014-06-09 14:01     ` Eric Sandeen
2014-06-09 14:29       ` Mark Tinguely [this message]
2014-06-06 21:04 ` [PATCH 2/3] xfs_fsr: create a cleanup/return target in packfile() Eric Sandeen
2014-06-09 13:02   ` Brian Foster
2014-06-06 21:06 ` [PATCH 3/3] xfs_fsr: test for more potential failures " Eric Sandeen
2014-06-09 13:02   ` Brian Foster

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=5395C4CA.6010206@sgi.com \
    --to=tinguely@sgi.com \
    --cc=bfoster@redhat.com \
    --cc=sandeen@redhat.com \
    --cc=sandeen@sandeen.net \
    --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