public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Eric Sandeen <sandeen@redhat.com>
To: xfs@oss.sgi.com
Cc: Eric Sandeen <sandeen@redhat.com>
Subject: [PATCH 1/8] libhandle: Guard against string overflow in path_to_fspath()
Date: Sat, 26 Jan 2013 16:40:25 -0600	[thread overview]
Message-ID: <1359240032-11576-2-git-send-email-sandeen@redhat.com> (raw)
In-Reply-To: <1359240032-11576-1-git-send-email-sandeen@redhat.com>

path_to_fspath does a blind strcpy into an array of
MAXPATHLEN; we should be sure to limit this so that it
does not go over the size of the array.

I don't think I see a way to get here today with a too-long
path, but I don't think it'll hurt to be defensive.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---
 libhandle/handle.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/libhandle/handle.c b/libhandle/handle.c
index b1ec5f2..9a232fa 100644
--- a/libhandle/handle.c
+++ b/libhandle/handle.c
@@ -158,7 +158,8 @@ path_to_fspath(char *path)
 	if (S_ISREG(statbuf.st_mode) || S_ISDIR(statbuf.st_mode))
 		return path;
 
-	strcpy(dirpath, path);
+	strncpy(dirpath, path, MAXPATHLEN);
+	dirpath[MAXPATHLEN-1] = '\0';
 	return dirname(dirpath);
 }
 
-- 
1.7.1

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

  reply	other threads:[~2013-01-26 22:40 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-26 22:40 [PATCH 0/8] xfsprogs: misc small fixes Eric Sandeen
2013-01-26 22:40 ` Eric Sandeen [this message]
2013-01-26 22:40 ` [PATCH 2/8] libxfs: initialize xfs_alloc_arg structures Eric Sandeen
2013-01-28  0:35   ` Dave Chinner
2013-01-28  2:41     ` Eric Sandeen
2013-01-29 18:49       ` Ben Myers
2013-01-28 14:21   ` Mark Tinguely
2013-01-26 22:40 ` [PATCH 3/8] libxfs: fix setup_cursor array allocation Eric Sandeen
2013-01-26 22:40 ` [PATCH 4/8] xfs_repair: Fix free of uninit ptr in xfs_acl_valid() error path Eric Sandeen
2013-01-26 22:40 ` [PATCH 5/8] xfs_fsr: guard against path string overflows Eric Sandeen
2013-01-26 22:40 ` [PATCH 6/8] xfs_fsr: check strdup results properly in initallfs() Eric Sandeen
2013-01-26 22:40 ` [PATCH 7/8] xfs_fsr: fix attribute no_change_count logic Eric Sandeen
2013-01-26 22:40 ` [PATCH 8/8] xfs_fsr: remove extraneous close() in fsrallfs() Eric Sandeen
2013-02-20 22:09 ` [PATCH 0/8] xfsprogs: misc small fixes Mark Tinguely
2013-02-21 17:02 ` Mark Tinguely

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=1359240032-11576-2-git-send-email-sandeen@redhat.com \
    --to=sandeen@redhat.com \
    --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