diff options
author | Darrick J. Wong <darrick.wong@oracle.com> | 2017-08-04 16:33:51 -0500 |
---|---|---|
committer | Eric Sandeen <sandeen@redhat.com> | 2017-08-04 16:33:51 -0500 |
commit | 5a707ca152dc4400f0e069e3ef3bfd557552d752 (patch) | |
tree | 769d515c74d7a42829e572e0d58ff6642beb02e3 | |
parent | 14f8b6810bd240cc58131483790a099fcf56c073 (diff) | |
download | xfsprogs-dev-5a707ca152dc4400f0e069e3ef3bfd557552d752.tar.gz |
xfs_repair: fix symlink target length checks by changing MAXPATHLEN to XFS_SYMLINK_MAXLEN
XFS has a maximum symlink target length of 1024 bytes; this is a
holdover from the Irix days. Unfortunately, the constant establishing
this was 'MAXPATHLEN', and is /not/ the same as the Linux MAXPATHLEN,
which is 4096.
The kernel enforces its 1024 byte MAXPATHLEN on symlink targets, but
xfsprogs picks up the (Linux) system 4096 byte MAXPATHLEN, which means
that xfs_repair doesn't complain about oversized symlinks.
Since this is an on-disk format constraint, put the define in the XFS
namespace. As a side effect of the rename, xfs_repair wil detect
oversized symlinks and clean them off the system.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
-rw-r--r-- | repair/dinode.c | 6 | ||||
-rw-r--r-- | repair/xfs_repair.c | 2 |
2 files changed, 4 insertions, 4 deletions
diff --git a/repair/dinode.c b/repair/dinode.c index da8721787b..f0053358da 100644 --- a/repair/dinode.c +++ b/repair/dinode.c @@ -1259,7 +1259,7 @@ null_check(char *name, int length) { int i; - ASSERT(length < MAXPATHLEN); + ASSERT(length < XFS_SYMLINK_MAXLEN); for (i = 0; i < length; i++, name++) { if (*name == '\0') @@ -1371,7 +1371,7 @@ process_symlink( blkmap_t *blkmap) { char *symlink; - char data[MAXPATHLEN]; + char data[XFS_SYMLINK_MAXLEN]; /* * check size against kernel symlink limits. we know @@ -1379,7 +1379,7 @@ process_symlink( * the inode is structurally ok so we don't have to check * for that */ - if (be64_to_cpu(dino->di_size) >= MAXPATHLEN) { + if (be64_to_cpu(dino->di_size) >= XFS_SYMLINK_MAXLEN) { do_warn(_("symlink in inode %" PRIu64 " too long (%llu chars)\n"), lino, (unsigned long long) be64_to_cpu(dino->di_size)); return(1); diff --git a/repair/xfs_repair.c b/repair/xfs_repair.c index ab60c0faaf..b2dd91b525 100644 --- a/repair/xfs_repair.c +++ b/repair/xfs_repair.c @@ -761,7 +761,7 @@ main(int argc, char **argv) glob_agcount = mp->m_sb.sb_agcount; chunks_pblock = mp->m_sb.sb_inopblock / XFS_INODES_PER_CHUNK; - max_symlink_blocks = libxfs_symlink_blocks(mp, MAXPATHLEN); + max_symlink_blocks = libxfs_symlink_blocks(mp, XFS_SYMLINK_MAXLEN); inodes_per_cluster = MAX(mp->m_sb.sb_inopblock, mp->m_inode_cluster_size >> mp->m_sb.sb_inodelog); |