From: Vladimir 'phcoder' Serbinenko Date: Thu, 3 May 2012 07:21:09 +0000 (+0200) Subject: * grub-core/fs/ufs.c (grub_ufs_lookup_symlink): Use proper check for X-Git-Tag: 2.00~275 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=59fd2aacd01d528a8668df8596f03d2e1e347e28;p=thirdparty%2Fgrub.git * grub-core/fs/ufs.c (grub_ufs_lookup_symlink): Use proper check for inline symlinks in addition to workaround. --- diff --git a/ChangeLog b/ChangeLog index afb2d5386..9fbf1b62a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2012-05-03 Vladimir Serbinenko + + * grub-core/fs/ufs.c (grub_ufs_lookup_symlink): Use proper check for + inline symlinks in addition to workaround. + 2012-05-03 Vladimir Serbinenko * grub-core/fs/xfs.c (grub_xfs_iterate_dir): Handle read_inode errors. diff --git a/grub-core/fs/ufs.c b/grub-core/fs/ufs.c index 1d0f7a088..9d4775e2d 100644 --- a/grub-core/fs/ufs.c +++ b/grub-core/fs/ufs.c @@ -401,7 +401,13 @@ grub_ufs_lookup_symlink (struct grub_ufs_data *data, int ino) if (++data->linknest > GRUB_UFS_MAX_SYMLNK_CNT) return grub_error (GRUB_ERR_SYMLINK_LOOP, N_("too deep nesting of symlinks")); - if (INODE_SIZE (data) <= sizeof (data->inode.symlink)) + /* Normally we should just check that data->inode.nblocks == 0. + However old Linux doesn't maintain nblocks correctly and so it's always + 0. If size is bigger than inline space then the symlink is surely not + inline. */ + /* Check against zero is paylindromic, no need to swap. */ + if (data->inode.nblocks == 0 + && INODE_SIZE (data) <= sizeof (data->inode.symlink)) grub_strcpy (symlink, (char *) INODE (data, symlink)); else grub_ufs_read_file (data, 0, 0, INODE_SIZE (data), symlink);