summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoreban <eban@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2000-08-30 05:34:05 +0000
committereban <eban@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2000-08-30 05:34:05 +0000
commitd89d02ba9512c1104b4815768629e62c1f178b1b (patch)
tree88a0801b7bc9a3f22ba041d753079b046a253046
parentc0b8c22ebe95264db794b3e277f1ec29091a3754 (diff)
eban
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_4@914 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog3
-rw-r--r--ext/Win32API/Win32API.c31
2 files changed, 30 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 12be01d958..a1b8dca26b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -13,6 +13,9 @@ Wed Aug 30 11:31:47 2000 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
* ext/Win32API/Win32API.c (Win32API_initialize): add the
arguments checking.
+ * ext/Win32API/Win32API.c (Win32API_initialize): add taint
+ checking. allow String object in the third argument.
+
Tue Aug 29 15:18:20 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
* ruby.c (proc_options): the value of -K may be empty.
diff --git a/ext/Win32API/Win32API.c b/ext/Win32API/Win32API.c
index d62e60e2f3..6558e38278 100644
--- a/ext/Win32API/Win32API.c
+++ b/ext/Win32API/Win32API.c
@@ -48,10 +48,13 @@ Win32API_initialize(self, dllname, proc, import, export)
VALUE str;
VALUE a_import;
VALUE *ptr;
+ char *s;
int i;
int len;
int ex;
+ Check_SafeStr(dllname);
+ Check_SafeStr(proc);
hdll = LoadLibrary(RSTRING(dllname)->ptr);
if (!hdll)
rb_raise(rb_eRuntimeError, "LoadLibrary: %s\n", RSTRING(dllname)->ptr);
@@ -70,11 +73,13 @@ Win32API_initialize(self, dllname, proc, import, export)
rb_iv_set(self, "__proc__", UINT2NUM((unsigned long)hproc));
a_import = rb_ary_new();
- if (!NIL_P(import)) {
- Check_Type(import, T_ARRAY);
+ switch (TYPE(import)) {
+ case T_NIL:
+ break;
+ case T_ARRAY:
ptr = RARRAY(import)->ptr;
for (i = 0, len = RARRAY(import)->len; i < len; i++) {
- Check_Type(ptr[i], T_STRING);
+ Check_SafeStr(ptr[i]);
switch (*(char *)RSTRING(ptr[i])->ptr) {
case 'N': case 'n': case 'L': case 'l':
rb_ary_push(a_import, INT2FIX(_T_NUMBER));
@@ -87,13 +92,31 @@ Win32API_initialize(self, dllname, proc, import, export)
break;
}
}
+ break;
+ default:
+ Check_SafeStr(import);
+ s = RSTRING(import)->ptr;
+ for (i = 0, len = RSTRING(import)->len; i < len; i++) {
+ switch (*s++) {
+ case 'N': case 'n': case 'L': case 'l':
+ rb_ary_push(a_import, INT2FIX(_T_NUMBER));
+ break;
+ case 'P': case 'p':
+ rb_ary_push(a_import, INT2FIX(_T_POINTER));
+ break;
+ case 'I': case 'i':
+ rb_ary_push(a_import, INT2FIX(_T_INTEGER));
+ break;
+ }
+ }
+ break;
}
rb_iv_set(self, "__import__", a_import);
if (NIL_P(export)) {
ex = _T_VOID;
} else {
- Check_Type(export, T_STRING);
+ Check_SafeStr(export);
switch (*RSTRING(export)->ptr) {
case 'V': case 'v':
ex = _T_VOID;