зеркало из https://github.com/github/ruby.git
win32ole.c: check method name length
* ext/win32ole/win32ole.c (fole_missing): reject too long method name, as Ruby string length is limited to long. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42662 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
91218a0e9f
Коммит
df3c472ac3
|
@ -4073,7 +4073,7 @@ fole_missing(int argc, VALUE *argv, VALUE self)
|
||||||
{
|
{
|
||||||
ID id;
|
ID id;
|
||||||
const char* mname;
|
const char* mname;
|
||||||
int n;
|
size_t n;
|
||||||
rb_check_arity(argc, 1, UNLIMITED_ARGUMENTS);
|
rb_check_arity(argc, 1, UNLIMITED_ARGUMENTS);
|
||||||
id = rb_to_id(argv[0]);
|
id = rb_to_id(argv[0]);
|
||||||
mname = rb_id2name(id);
|
mname = rb_id2name(id);
|
||||||
|
@ -4081,14 +4081,19 @@ fole_missing(int argc, VALUE *argv, VALUE self)
|
||||||
rb_raise(rb_eRuntimeError, "fail: unknown method or property");
|
rb_raise(rb_eRuntimeError, "fail: unknown method or property");
|
||||||
}
|
}
|
||||||
n = strlen(mname);
|
n = strlen(mname);
|
||||||
|
#if SIZEOF_SIZE_T > SIZEOF_LONG
|
||||||
|
if (n >= LONG_MAX) {
|
||||||
|
rb_raise(rb_eRuntimeError, "too long method or property name");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
if(mname[n-1] == '=') {
|
if(mname[n-1] == '=') {
|
||||||
rb_check_arity(argc, 2, 2);
|
rb_check_arity(argc, 2, 2);
|
||||||
argv[0] = rb_enc_str_new(mname, n-1, cWIN32OLE_enc);
|
argv[0] = rb_enc_str_new(mname, (long)(n-1), cWIN32OLE_enc);
|
||||||
|
|
||||||
return ole_propertyput(self, argv[0], argv[1]);
|
return ole_propertyput(self, argv[0], argv[1]);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
argv[0] = rb_enc_str_new(mname, n, cWIN32OLE_enc);
|
argv[0] = rb_enc_str_new(mname, (long)n, cWIN32OLE_enc);
|
||||||
return ole_invoke(argc, argv, self, DISPATCH_METHOD|DISPATCH_PROPERTYGET, FALSE);
|
return ole_invoke(argc, argv, self, DISPATCH_METHOD|DISPATCH_PROPERTYGET, FALSE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче