Przeglądaj źródła

client: when relaying frames, make sure the source peer ID is the peer sending the frame

ambrop7 15 lat temu
rodzic
commit
7f24efde2c
1 zmienionych plików z 13 dodań i 1 usunięć
  1. 13 1
      client/client.c

+ 13 - 1
client/client.c

@@ -2122,13 +2122,25 @@ void peer_recv_handler_send (struct peer_data *peer, uint8_t *data, int data_len
             goto out;
         }
         
+        // provided source ID must be the peer sending the frame
+        if (src_peer != peer) {
+            peer_log(peer, BLOG_NOTICE, "relay source must be the sending peer");
+            goto out;
+        }
+        
         // lookup destination peer
         struct peer_data *dest_peer = find_peer_by_id(id);
-        if (!dest_peer || dest_peer == src_peer) {
+        if (!dest_peer) {
             peer_log(peer, BLOG_NOTICE, "relay destination peer not known");
             goto out;
         }
         
+        // destination cannot be source
+        if (dest_peer == src_peer) {
+            peer_log(peer, BLOG_NOTICE, "relay destination cannot be the source");
+            goto out;
+        }
+        
         relay_dest = dest_peer;
     }