aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs
diff options
context:
space:
mode:
authorFilipe David Borba Manana <fdmanana@gmail.com>2014-01-21 18:36:38 -0500
committerChris Mason <clm@fb.com>2014-01-28 16:20:43 -0500
commitf74b86d85533a98ef7f573487af38f9dd514becb (patch)
tree86ad2a4b8d7d39076c0df8789040ae0bc82287bf /fs/btrfs
parentc41570c9d29764f797fa35490d72b7395a0105c3 (diff)
Btrfs: fix snprintf usage by send's gen_unique_name
The buffer size argument passed to snprintf must account for the trailing null byte added by snprintf, and it returns a value >= then sizeof(buffer) when the string can't fit in the buffer. Since our buffer has a size of 64 characters, and the maximum orphan name we can generate is 63 characters wide, we must pass 64 as the buffer size to snprintf, and not 63. Signed-off-by: Filipe David Borba Manana <fdmanana@gmail.com> Reviewed-by: David Sterba <dsterba@suse.cz> Signed-off-by: Josef Bacik <jbacik@fb.com> Signed-off-by: Chris Mason <clm@fb.com>
Diffstat (limited to 'fs/btrfs')
-rw-r--r--fs/btrfs/send.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c
index aa60cbe7066c..fc1f0abb8fe4 100644
--- a/fs/btrfs/send.c
+++ b/fs/btrfs/send.c
@@ -1336,7 +1336,7 @@ static int gen_unique_name(struct send_ctx *sctx,
1336 return -ENOMEM; 1336 return -ENOMEM;
1337 1337
1338 while (1) { 1338 while (1) {
1339 len = snprintf(tmp, sizeof(tmp) - 1, "o%llu-%llu-%llu", 1339 len = snprintf(tmp, sizeof(tmp), "o%llu-%llu-%llu",
1340 ino, gen, idx); 1340 ino, gen, idx);
1341 if (len >= sizeof(tmp)) { 1341 if (len >= sizeof(tmp)) {
1342 /* should really not happen */ 1342 /* should really not happen */