diff --git a/src/bitcoindjs.cc b/src/bitcoindjs.cc index 20ee200e..f8d7bc31 100644 --- a/src/bitcoindjs.cc +++ b/src/bitcoindjs.cc @@ -3745,7 +3745,21 @@ NAN_METHOD(HookPackets) { o->Set(NanNew("flags"), NanNew(filter.nFlags)); } } else if (strCommand == "filteradd") { - ; + vector vData; + cur->vRecv >> vData; + + // Nodes must NEVER send a data item > 520 bytes (the max size for a script data object, + // and thus, the maximum size any matched object can have) in a filteradd message + if (vData.size() > MAX_SCRIPT_ELEMENT_SIZE) { + o->Set(NanNew("misbehaving"), NanNew(true)); + } else { + LOCK(pfrom->cs_filter); + if (pfrom->pfilter) { + o->Set(NanNew("data"), NanNew(vData.GetHex().c_str())); + } else { + o->Set(NanNew("misbehaving"), NanNew(true)); + } + } } else if (strCommand == "filterclear") { ; } else if (strCommand == "reject") {