ruby-changes:40997
From: nobu <ko1@a...>
Date: Sun, 13 Dec 2015 18:25:22 +0900 (JST)
Subject: [ruby-changes:40997] nobu:r53076 (trunk): tkutil.c: array length
nobu 2015-12-13 18:25:15 +0900 (Sun, 13 Dec 2015) New Revision: 53076 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=53076 Log: tkutil.c: array length * ext/tk/tkutil/tkutil.c (cbsubst_table_setup): check length of argument arrays for each access, as callback methods can modify them. reported by Marcin 'Icewall' Noga of Cisco Talos. Modified files: trunk/ChangeLog trunk/ext/tk/tkutil/tkutil.c Index: ChangeLog =================================================================== --- ChangeLog (revision 53075) +++ ChangeLog (revision 53076) @@ -1,4 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 -Sun Dec 13 18:23:37 2015 Nobuyoshi Nakada <nobu@r...> +Sun Dec 13 18:25:16 2015 Nobuyoshi Nakada <nobu@r...> + + * ext/tk/tkutil/tkutil.c (cbsubst_table_setup): check length of + argument arrays for each access, as callback methods can modify + them. reported by Marcin 'Icewall' Noga of Cisco Talos. * ext/tk/tkutil/tkutil.c (cbsubst_table_setup): check types of argument elements. reported by Marcin 'Icewall' Noga of Cisco Index: ext/tk/tkutil/tkutil.c =================================================================== --- ext/tk/tkutil/tkutil.c (revision 53075) +++ ext/tk/tkutil/tkutil.c (revision 53076) @@ -1568,7 +1568,7 @@ cbsubst_table_setup(argc, argv, self) https://github.com/ruby/ruby/blob/trunk/ext/tk/tkutil/tkutil.c#L1568 const VALUE *infp; ID id; struct cbsubst_info *subst_inf; - long idx, len; + long idx; unsigned char chr; /* accept (key_inf, proc_inf) or (key_inf, longkey_inf, procinf) */ @@ -1594,8 +1594,7 @@ cbsubst_table_setup(argc, argv, self) https://github.com/ruby/ruby/blob/trunk/ext/tk/tkutil/tkutil.c#L1594 * type ==> char code or string * ivar ==> symbol */ - len = RARRAY_LEN(key_inf); - for(idx = 0; idx < len; idx++) { + for(idx = 0; idx < RARRAY_LEN(key_inf); idx++) { inf = RARRAY_AREF(key_inf, idx); if (!RB_TYPE_P(inf, T_ARRAY)) continue; if (RARRAY_LEN(inf) < 3) continue; @@ -1622,8 +1621,7 @@ cbsubst_table_setup(argc, argv, self) https://github.com/ruby/ruby/blob/trunk/ext/tk/tkutil/tkutil.c#L1621 * type ==> char code or string * ivar ==> symbol */ - len = RARRAY_LEN(longkey_inf); - for(idx = 0; idx < len; idx++) { + for(idx = 0; idx < RARRAY_LEN(longkey_inf); idx++) { inf = RARRAY_AREF(longkey_inf, idx); if (!RB_TYPE_P(inf, T_ARRAY)) continue; if (RARRAY_LEN(inf) < 3) continue; @@ -1652,9 +1650,7 @@ cbsubst_table_setup(argc, argv, self) https://github.com/ruby/ruby/blob/trunk/ext/tk/tkutil/tkutil.c#L1650 * type ==> char code or string * proc ==> proc/method/obj (must respond to 'call') */ - len = RARRAY_LEN(proc_inf); - for(idx = 0; idx < len; idx++) { - VALUE type, proc; + for(idx = 0; idx < RARRAY_LEN(proc_inf); idx++) { inf = RARRAY_AREF(proc_inf, idx); if (!RB_TYPE_P(inf, T_ARRAY)) continue; if (RARRAY_LEN(inf) < 2) continue; -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/