summaryrefslogtreecommitdiff
path: root/cmds-inspect.c
diff options
context:
space:
mode:
authorMark Fasheh <mfasheh@suse.de>2013-02-14 10:29:50 -0800
committerDavid Sterba <dsterba@suse.cz>2013-02-19 11:15:30 +0100
commit3b85739dd6c63c8f94f87d6574494919d2c1119f (patch)
tree2fd7faa3e3bf3251ed59d5ce10cb2e6bede805ec /cmds-inspect.c
parentd065d63057c249e109159d0620ce461954b1bc73 (diff)
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 <mfasheh@suse.de>
Diffstat (limited to 'cmds-inspect.c')
-rw-r--r--cmds-inspect.c11
1 files changed, 7 insertions, 4 deletions
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: