[Ocfs2-tools-devel] [PATCH] tunefs.ocfs2: Fix overflow when calling uuid_unparse.

Tao Ma tao.ma at oracle.com
Wed Jul 16 23:51:59 PDT 2008


uuid_unparse will convert the supplied UUID uu from the binary
representation into a 36-byte string, so the old uuid string(which
only have 33 bytes allocated) will overflow and make tunefs.ocfs2
segment fault.

Signed-off-by: Tao Ma <tao.ma at oracle.com>
---
 tunefs.ocfs2/query.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/tunefs.ocfs2/query.c b/tunefs.ocfs2/query.c
index ca79930..46418eb 100644
--- a/tunefs.ocfs2/query.c
+++ b/tunefs.ocfs2/query.c
@@ -26,6 +26,9 @@
 #include <printf.h>
 #include <glib.h>
 
+/*This number is from the man page of uuid_unparse. */
+#define UUID_UNPARSE_LEN	36
+
 extern ocfs2_filesys *fs_gbl;
 extern ocfs2_tune_opts opts;
 
@@ -163,7 +166,7 @@ static int handle_label(FILE *stream, const struct printf_info *info,
 static int handle_uuid(FILE *stream, const struct printf_info *info,
 		       const void *const *args)
 {
-	char uuid[OCFS2_VOL_UUID_LEN * 2 + 1];
+	char uuid[UUID_UNPARSE_LEN + 1];
 
 	uuid_unparse(OCFS2_RAW_SB(fs_gbl->fs_super)->s_uuid, uuid);
 
-- 
1.5.4.GIT



More information about the Ocfs2-tools-devel mailing list