linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] debugfs: add sanity check to make sure we never shift 64 bits right
@ 2013-01-28 14:06 Theodore Ts'o
  0 siblings, 0 replies; only message in thread
From: Theodore Ts'o @ 2013-01-28 14:06 UTC (permalink / raw)
  To: Ext4 Developers List; +Cc: xi.wang, Theodore Ts'o

In the tables which are used to parse the fields for the set_fields
command, there should never be a entry which has a size set to 8
bytes, and two pointers defined.  Not only would it result in
undefined behavior in the compiled code, it doesn't make any sense and
is definitely a bug.

Reported-by: Xi Wang <xi.wang@gmail.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
---
 debugfs/set_fields.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/debugfs/set_fields.c b/debugfs/set_fields.c
index 08bfd8d..5c86d74 100644
--- a/debugfs/set_fields.c
+++ b/debugfs/set_fields.c
@@ -389,7 +389,10 @@ static errcode_t parse_uint(struct field_set_info *info, char *field,
 	n = num & mask;
 	switch (size) {
 	case 8:
-		*u.ptr64 = n;
+		/* Should never get here */
+		fprintf(stderr, "64-bit field %s has a second 64-bit field\n"
+			"defined; BUG?!?\n", info->name);
+		*u.ptr64 = 0;
 		break;
 	case 4:
 		*u.ptr32 = n;
-- 
1.7.12.rc0.22.gcdd159b


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2013-01-28 14:06 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-28 14:06 [PATCH] debugfs: add sanity check to make sure we never shift 64 bits right Theodore Ts'o

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).