aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/send.c
diff options
context:
space:
mode:
authorFilipe Manana <fdmanana@gmail.com>2014-05-21 12:38:13 -0400
committerChris Mason <clm@fb.com>2014-06-06 15:00:46 -0400
commit01a9a8a9e20012f5676ec9cd16b6aed08b267066 (patch)
treeb824de5fffb1f0acccc79de5575b47d6298f97ec /fs/btrfs/send.c
parentfad01e866afdbe01a1f3ec06a39c3a8b9e197014 (diff)
Btrfs: send, fix corrupted path strings for long paths
If a path has more than 230 characters, we allocate a new buffer to use for the path, but we were forgotting to copy the contents of the previous buffer into the new one, which has random content from the kmalloc call. Test: mkfs.btrfs -f /dev/sdd mount /dev/sdd /mnt TEST_PATH="/mnt/fdmanana/.config/google-chrome-mysetup/Default/Pepper_Data/Shockwave_Flash/WritableRoot/#SharedObjects/JSHJ4ZKN/s.wsj.net/[[IMPORT]]/players.edgesuite.net/flash/plugins/osmf/advanced-streaming-plugin/v2.7/osmf1.6/Ak#" mkdir -p $TEST_PATH echo "hello world" > $TEST_PATH/amaiAdvancedStreamingPlugin.txt btrfs subvolume snapshot -r /mnt /mnt/mysnap1 btrfs send /mnt/mysnap1 -f /tmp/1.snap A test for xfstests follows. Signed-off-by: Filipe David Borba Manana <fdmanana@gmail.com> Cc: Marc Merlin <marc@merlins.org> Tested-by: Marc MERLIN <marc@merlins.org> Signed-off-by: Chris Mason <clm@fb.com>
Diffstat (limited to 'fs/btrfs/send.c')
-rw-r--r--fs/btrfs/send.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c
index fd38b5053479..484aacac2c89 100644
--- a/fs/btrfs/send.c
+++ b/fs/btrfs/send.c
@@ -360,10 +360,13 @@ static int fs_path_ensure_buf(struct fs_path *p, int len)
360 /* 360 /*
361 * First time the inline_buf does not suffice 361 * First time the inline_buf does not suffice
362 */ 362 */
363 if (p->buf == p->inline_buf) 363 if (p->buf == p->inline_buf) {
364 tmp_buf = kmalloc(len, GFP_NOFS); 364 tmp_buf = kmalloc(len, GFP_NOFS);
365 else 365 if (tmp_buf)
366 memcpy(tmp_buf, p->buf, old_buf_len);
367 } else {
366 tmp_buf = krealloc(p->buf, len, GFP_NOFS); 368 tmp_buf = krealloc(p->buf, len, GFP_NOFS);
369 }
367 if (!tmp_buf) 370 if (!tmp_buf)
368 return -ENOMEM; 371 return -ENOMEM;
369 p->buf = tmp_buf; 372 p->buf = tmp_buf;