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

ruby-changes:1786

From: ko1@a...
Date: 26 Aug 2007 06:58:04 +0900
Subject: [ruby-changes:1786] suke - Ruby:r13277 (trunk): * ext/win32ole/win32ole.c (ole_wc2mb, reg_enum_key): allocate

suke	2007-08-26 06:57:46 +0900 (Sun, 26 Aug 2007)

  New Revision: 13277

  Modified files:
    trunk/ChangeLog
    trunk/ext/win32ole/win32ole.c

  Log:
    * ext/win32ole/win32ole.c (ole_wc2mb, reg_enum_key): allocate 
      buffer should be NULL terminated.


  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=13277&r2=13276
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ext/win32ole/win32ole.c?r1=13277&r2=13276

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 13276)
+++ ChangeLog	(revision 13277)
@@ -1,3 +1,8 @@
+Sun Aug 26 06:51:46 2007  Masaki Suketa  <masaki.suketa@n...>
+
+	* ext/win32ole/win32ole.c (ole_wc2mb, reg_enum_key): allocate 
+	  buffer should be NULL terminated.
+
 Sun Aug 26 06:04:13 2007  Koichi Sasada  <ko1@a...>
 
 	* insnhelper.ci (vm_setup_method): reorder code for branch prediction.
Index: ext/win32ole/win32ole.c
===================================================================
--- ext/win32ole/win32ole.c	(revision 13276)
+++ ext/win32ole/win32ole.c	(revision 13277)
@@ -116,7 +116,7 @@
 
 #define WC2VSTR(x) ole_wc2vstr((x), TRUE)
 
-#define WIN32OLE_VERSION "1.0.4"
+#define WIN32OLE_VERSION "1.0.5"
 
 typedef HRESULT (STDAPICALLTYPE FNCOCREATEINSTANCEEX)
     (REFCLSID, IUnknown*, DWORD, COSERVERINFO*, DWORD, MULTI_QI*);
@@ -768,8 +768,9 @@
     LPSTR pm;
     size = WideCharToMultiByte(cWIN32OLE_cp, 0, pw, -1, NULL, 0, NULL, NULL);
     if (size) {
-        pm = ALLOC_N(char, size);    
+        pm = ALLOC_N(char, size + 1);    
         WideCharToMultiByte(cWIN32OLE_cp, 0, pw, -1, pm, size, NULL, NULL);
+        pm[size] = '\0';
     }
     else {
         pm = ALLOC_N(char, 1);
@@ -1913,12 +1914,13 @@
 static VALUE
 reg_enum_key(HKEY hkey, DWORD i)
 {
-    char buf[BUFSIZ];
+    char buf[BUFSIZ + 1];
     DWORD size_buf = sizeof(buf);
     FILETIME ft;
     LONG err = RegEnumKeyEx(hkey, i, buf, &size_buf,
                             NULL, NULL, NULL, &ft);
     if(err == ERROR_SUCCESS) {
+        buf[BUFSIZ] = '\0';
         return rb_str_new2(buf);
     }
     return Qnil;

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

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