]> www.infradead.org Git - mtd-utils.git/commit
mkfs.ubifs: rewrite path checking
authorArtem Bityutskiy <artem.bityutskiy@linux.intel.com>
Wed, 10 Oct 2012 11:23:18 +0000 (14:23 +0300)
committerArtem Bityutskiy <artem.bityutskiy@linux.intel.com>
Thu, 11 Oct 2012 07:56:58 +0000 (10:56 +0300)
commit17f66065837415e0b1b4d619f12a2219af987c80
treefd4270c54ee0a9f0c733d76f38d3d7829de4b40a
parent56840a198a70604ece50d9d727cebcc28930ab4c
mkfs.ubifs: rewrite path checking

We use the 'in_path()' function to check whether the output image is
withing the mkfs.ubifs root directory or not. However, this function
is not correct and it fails for the following situation, as
Marcus Prebble <marcus.prebble@axis.com> reports:

1. We have our root file-system mounted at / and want to build an image
   out of it.
2. We have tmpfs mounted at /tmp
3. We mount the root file-system under /tmp/newroot
4. We run mkfs.ubifs with -r /tmp/newroot -o /tmp/image

And this fails. It fails because 'in_path()' misses this use-case.

This patch re-implements the check completely. Now we use 'realpath()'
to find canonical paths and just check that the output file is not
under the root mkfs.ubifs directory.

Reported-by: Marcus Prebble <marcus.prebble@axis.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Tested-by: Marcus Prebble <marcus.prebble@axis.com>
mkfs.ubifs/mkfs.ubifs.c