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

ruby-changes:28292

From: nobu <ko1@a...>
Date: Thu, 18 Apr 2013 16:20:34 +0900 (JST)
Subject: [ruby-changes:28292] nobu:r40344 (trunk): pack.c: refix unpack base64

nobu	2013-04-18 16:20:25 +0900 (Thu, 18 Apr 2013)

  New Revision: 40344

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

  Log:
    pack.c: refix unpack base64
    
    * pack.c (pack_unpack): increase buffer size to fix buffer overflow,
      and fix garbages just after unpacking without missing paddings.
      [Bug #8286]

  Modified files:
    trunk/ChangeLog
    trunk/pack.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 40343)
+++ ChangeLog	(revision 40344)
@@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Thu Apr 18 16:20:21 2013  Nobuyoshi Nakada  <nobu@r...>
+
+	* pack.c (pack_unpack): increase buffer size to fix buffer overflow,
+	  and fix garbages just after unpacking without missing paddings.
+	  [Bug #8286]
+
 Thu Apr 18 13:35:54 2013  NARUSE, Yui  <naruse@r...>
 
 	* pack.c (pack_unpack): output characters even if the input doesn't
Index: pack.c
===================================================================
--- pack.c	(revision 40343)
+++ pack.c	(revision 40344)
@@ -1941,7 +1941,7 @@ pack_unpack(VALUE str, VALUE fmt) https://github.com/ruby/ruby/blob/trunk/pack.c#L1941
 
 	  case 'm':
 	    {
-		VALUE buf = infected_str_new(0, (send - s + 2)*3/4, str); /* +2 is for skipping paddings */
+		VALUE buf = infected_str_new(0, (send - s + 3)*3/4, str); /* +3 is for skipping paddings */
 		char *ptr = RSTRING_PTR(buf);
 		int a = -1,b = -1,c = 0,d = 0;
 		static signed char b64_xtable[256];
@@ -2004,6 +2004,7 @@ pack_unpack(VALUE str, VALUE fmt) https://github.com/ruby/ruby/blob/trunk/pack.c#L2004
 			*ptr++ = castchar(a << 2 | b >> 4);
 			*ptr++ = castchar(b << 4 | c >> 2);
 			*ptr++ = castchar(c << 6 | d);
+			a = -1;
 		    }
 		    if (a != -1 && b != -1) {
 			if (c == -1)

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

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