Permalink
Browse files

C-Ares shouldn't iterate over all Object.prototype elements

and furthermore error out of one of them isn't a DNS option.

Test case by Ben Lund <ben.lund@gmail.com>; additional help from Tim Caswell
<tim@creationix.com>.
  • Loading branch information...
1 parent 715e119 commit cc9d5ab546e92ff9e56e4355e0cf0e557221bbab @ry ry committed Apr 11, 2010
Showing with 14 additions and 15 deletions.
  1. +6 −15 src/node_cares.cc
  2. +8 −0 test/simple/test-regression-object-prototype.js
View
@@ -422,22 +422,13 @@ Handle<Value> Channel::New(const Arguments& args) {
}
Local<Object> options_o = Local<Object>::Cast(args[0]);
- Local<Array> keys = options_o->GetPropertyNames();
- int length = keys->Length();
-
- for (int i = 0; i < length; ++i) {
- Local<String> opt = Local<String>::Cast(keys->Get(Integer::New(i)));
-
- if (opt->Equals(String::New("SOCK_STATE_CB"))) {
- c->handle_->Set(callback_symbol, options_o->Get(opt));
- options.sock_state_cb_data = c;
- options.sock_state_cb = Channel::SockStateCb;
- optmask |= ARES_OPT_SOCK_STATE_CB;
- continue;
- }
- return ThrowException(Exception::Error(
- String::New("Unknown Option")));
+ Local<Value> cb = options_o->Get(String::NewSymbol("SOCK_STATE_CB"));
+ if (!cb.IsEmpty()) {
+ c->handle_->Set(callback_symbol, cb);
+ options.sock_state_cb_data = c;
+ options.sock_state_cb = Channel::SockStateCb;
+ optmask |= ARES_OPT_SOCK_STATE_CB;
}
}
@@ -0,0 +1,8 @@
+var sys = require('sys');
+
+//sys.puts('puts before');
+
+Object.prototype.xadsadsdasasdxx = function () {
+};
+
+sys.puts('puts after');

0 comments on commit cc9d5ab

Please sign in to comment.