rx-honor-only-client-initiated-debug-and-version-packets-to-prevent-loop-20010719
authorNickolai Zeldovich <kolya@mit.edu>
Fri, 20 Jul 2001 16:59:43 +0000 (16:59 +0000)
committerDerrick Brashear <shadow@dementia.org>
Fri, 20 Jul 2001 16:59:43 +0000 (16:59 +0000)
"This patch makes Rx only honor client-initiated Version and Debug
packets, and respond to them without the "client-initiated" flag.
All existing code sends Version and Debug queries from the client
with the appropriate flag set.  With the current code, one could
easily create a UDP packet loop between two Rx services."

src/rx/rx_packet.c

index 85136df..5cdf7de 100644 (file)
@@ -1112,6 +1112,17 @@ struct rx_packet *rxi_ReceiveDebugPacket(ap, asocket, ahost, aport, istack)
     afs_int32 tl;
     struct rx_serverQueueEntry *np, *nqe;
 
+    /*
+     * Only respond to client-initiated Rx debug packets,
+     * and clear the client flag in the response.
+     */
+    if (ap->header.flags & RX_CLIENT_INITIATED) {
+       ap->header.flags = ap->header.flags & ~RX_CLIENT_INITIATED;
+       rxi_EncodePacketHeader(ap);
+    } else {
+       return ap;
+    }
+
     rx_packetread(ap, 0, sizeof(struct rx_debugIn), (char *)&tin);
     /* all done with packet, now set length to the truth, so we can 
      * reuse this packet */
@@ -1384,13 +1395,27 @@ struct rx_packet *rxi_ReceiveVersionPacket(ap, asocket, ahost, aport, istack)
   register struct rx_packet *ap;
   int istack;
 {
-  afs_int32 tl;
-       rx_packetwrite(ap, 0, 65, cml_version_number+4);
-        tl = ap->length;
+    afs_int32 tl;
+
+    /*
+     * Only respond to client-initiated version requests, and
+     * clear that flag in the response.
+     */
+    if (ap->header.flags & RX_CLIENT_INITIATED) {
+       char buf[66];
+
+       ap->header.flags = ap->header.flags & ~RX_CLIENT_INITIATED;
+       rxi_EncodePacketHeader(ap);
+       bzero(buf, sizeof(buf));
+       snprintf(buf, sizeof(buf), "%s", cml_version_number+4);
+       rx_packetwrite(ap, 0, 65, buf);
+       tl = ap->length;
        ap->length = 65;
        rxi_SendDebugPacket(ap, asocket, ahost, aport, istack);
-        ap->length = tl;
-       return ap;
+       ap->length = tl;
+    }
+
+    return ap;
 }