]> jfr.im git - solanum.git/commitdiff
ssld: change_connid may be called with an unknown ID
authorSimon Arlott <sa.me.uk>
Wed, 10 Feb 2016 21:22:50 +0000 (21:22 +0000)
committerSimon Arlott <sa.me.uk>
Wed, 10 Feb 2016 21:22:50 +0000 (21:22 +0000)
If change_connid is called with an unknown ID, conn will be
NULL, check this with an assert and then respond by reporting
the new ID as closed instead of dereferencing a NULL pointer.

ssld/ssld.c

index 3583ba0827c29d185f5fb03544e64e2162d72737..f187cd57dd51b4458ac0b6a0f82bf973814db851 100644 (file)
@@ -829,6 +829,20 @@ change_connid(mod_ctl_t *ctl, mod_ctl_buf_t *ctlb)
        uint32_t id = buf_to_uint32(&ctlb->buf[1]);
        uint32_t newid = buf_to_uint32(&ctlb->buf[5]);
        conn_t *conn = conn_find_by_id(id);
+       lrb_assert(conn != NULL);
+       if(conn == NULL)
+       {
+               char buf[256];
+               int len;
+
+               buf[0] = 'D';
+               uint32_to_buf(&buf[1], newid);
+               sprintf(&buf[5], "connid %d does not exist", id);
+               len = (strlen(&buf[5]) + 1) + 5;
+               mod_cmd_write_queue(ctl, buf, len);
+
+               return;
+       }
        rb_dlinkDelete(&conn->node, connid_hash(conn->id));
        SetZipSSL(conn);
        conn->id = newid;