From: Mark Fasheh Date: Thu, 14 Feb 2013 18:29:50 +0000 (-0800) Subject: btrfs-progs: Fix pointer math in __ino_to_path_fd X-Git-Tag: upstream/4.16.1~3438 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3b85739dd6c63c8f94f87d6574494919d2c1119f;p=platform%2Fupstream%2Fbtrfs-progs.git btrfs-progs: Fix pointer math in __ino_to_path_fd We are casting an array of u64 values into a char ** array so when we dereference this array (as a char **) on a 32 bit system we're then re-casting that back to a 32 bit value. This causes problems when we try to print those strings. Signed-off-by: Mark Fasheh --- diff --git a/cmds-inspect.c b/cmds-inspect.c index ff6d00f..7761759 100644 --- a/cmds-inspect.c +++ b/cmds-inspect.c @@ -63,12 +63,15 @@ static int __ino_to_path_fd(u64 inum, int fd, int verbose, const char *prepend) fspath->elem_cnt, fspath->elem_missed); for (i = 0; i < fspath->elem_cnt; ++i) { - char **str = (char **)fspath->val; - str[i] += (unsigned long)fspath->val; + u64 ptr; + char *str; + ptr = (u64)(unsigned long)fspath->val; + ptr += fspath->val[i]; + str = (char *)(unsigned long)ptr; if (prepend) - printf("%s/%s\n", prepend, str[i]); + printf("%s/%s\n", prepend, str); else - printf("%s\n", str[i]); + printf("%s\n", str); } out: