Skip to content

Commit

Permalink
btrfs: send: replace check with an assert in gen_unique_name
Browse files Browse the repository at this point in the history
The buffer passed to snprintf can hold the fully expanded format string,
64 = 3x largest ULL + 3x char + trailing null.  I don't think that removing the
check entirely is a good idea, hence the ASSERT.

Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Josef Bacik <jbacik@fb.com>
  • Loading branch information
David Sterba authored and Josef Bacik committed Mar 10, 2014
1 parent 5ed7f9f commit 64792f2
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions fs/btrfs/send.c
Original file line number Diff line number Diff line change
Expand Up @@ -1418,11 +1418,7 @@ static int gen_unique_name(struct send_ctx *sctx,
while (1) {
len = snprintf(tmp, sizeof(tmp), "o%llu-%llu-%llu",
ino, gen, idx);
if (len >= sizeof(tmp)) {
/* should really not happen */
ret = -EOVERFLOW;
goto out;
}
ASSERT(len < sizeof(tmp));

di = btrfs_lookup_dir_item(NULL, sctx->send_root,
path, BTRFS_FIRST_FREE_OBJECTID,
Expand Down

0 comments on commit 64792f2

Please sign in to comment.