[前][次][番号順一覧][スレッド一覧]

ruby-changes:34771

From: nobu <ko1@a...>
Date: Fri, 18 Jul 2014 01:55:05 +0900 (JST)
Subject: [ruby-changes:34771] nobu:r46854 (trunk): iseq.h: check range

nobu	2014-07-18 01:54:59 +0900 (Fri, 18 Jul 2014)

  New Revision: 46854

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=46854

  Log:
    iseq.h: check range
    
    * iseq.h (iseq_catch_table_bytes): check range and suppress a
      warning.

  Modified files:
    trunk/iseq.h
Index: iseq.h
===================================================================
--- iseq.h	(revision 46853)
+++ iseq.h	(revision 46854)
@@ -76,8 +76,12 @@ PACKED_STRUCT_UNALIGNED(struct iseq_catc https://github.com/ruby/ruby/blob/trunk/iseq.h#L76
 static inline int
 iseq_catch_table_bytes(int n)
 {
-    return sizeof(struct iseq_catch_table) +
-           (n - 1) * sizeof(struct iseq_catch_table_entry);
+    enum {
+	catch_table_entries_max = (INT_MAX - sizeof(struct iseq_catch_table)) / sizeof(struct iseq_catch_table_entry)
+    };
+    if (n > catch_table_entries_max) rb_fatal("too large iseq_catch_table - %d", n);
+    return (int)(sizeof(struct iseq_catch_table) +
+		 (n - 1) * sizeof(struct iseq_catch_table_entry));
 }
 
 #define INITIAL_ISEQ_COMPILE_DATA_STORAGE_BUFF_SIZE (512)

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]