Reject oversized addr messages
authorMatt Corallo <git@bluematt.me>
Mon, 20 May 2019 22:13:10 +0000 (18:13 -0400)
committerMatt Corallo <git@bluematt.me>
Mon, 20 May 2019 22:15:37 +0000 (18:15 -0400)
src/main.rs

index 7f9409055c6102fca15108528acf8db37ab5c660..bdb8aa1d81bc2f95b908680cfe10413c3f3fc90d 100644 (file)
@@ -135,6 +135,12 @@ pub fn scan_node(scan_time: Instant, node: SocketAddr) {
                                        }
                                },
                                NetworkMessage::Addr(addrs) => {
+                                       if addrs.len() > 1000 {
+                                               state_lock.fail_reason = AddressState::ProtocolViolation;
+                                               printer.add_line(format!("Updating {} to ProtocolViolation due to oversized addr: {}", node, addrs.len()), true);
+                                               state_lock.recvd_addrs = false;
+                                               return future::err(());
+                                       }
                                        state_lock.recvd_addrs = true;
                                        unsafe { DATA_STORE.as_ref().unwrap() }.add_fresh_nodes(&addrs);
                                },