All of lore.kernel.org
 help / color / mirror / Atom feed
From: Wang Shilong <wangshilong1991@gmail.com>
To: linux-btrfs@vger.kernel.org
Cc: wangshilong1991@gmail.com
Subject: [PATCH 1/4] Btrfs-progs: add check for level and id in case overflow happens
Date: Mon, 25 Feb 2013 22:02:37 +0800	[thread overview]
Message-ID: <1361800957-1947-1-git-send-email-wangshilong1991@gmail.com> (raw)

From: Wang Shilong <wangsl-fnst@cn.fujitsu.com>

qgroupid(u64) is splitted into two parts:

	1) the lower 48 bit are used to represent id
	2) the higher 16 bit are used to represent level
So the check for id and level are necessary.

Signed-off-by: Wang Shilong <wangsl-fnst@cn.fujitsu.com>
---
 qgroup.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/qgroup.c b/qgroup.c
index dafde12..fbb50ab 100644
--- a/qgroup.c
+++ b/qgroup.c
@@ -34,11 +34,11 @@ u64 parse_qgroupid(char *p)
 		return id;
 	}
 	level = strtoull(p, &ptr_parse_end, 10);
-	if (ptr_parse_end != s)
+	if (ptr_parse_end != s || level >= (1ll << 16))
 		goto err;
 
 	id = strtoull(s+1, &ptr_parse_end, 10);
-	if (ptr_parse_end != ptr_src_end)
+	if (ptr_parse_end != ptr_src_end || id >= (1ll << 48))
 		goto  err;
 
 	return (level << 48) | id;
-- 
1.7.7.6


                 reply	other threads:[~2013-02-25 14:02 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1361800957-1947-1-git-send-email-wangshilong1991@gmail.com \
    --to=wangshilong1991@gmail.com \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.