]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
validate dmaster on a client fetch request
authorAndrew Tridgell <tridge@samba.org>
Wed, 18 Apr 2007 08:39:02 +0000 (18:39 +1000)
committerAndrew Tridgell <tridge@samba.org>
Wed, 18 Apr 2007 08:39:02 +0000 (18:39 +1000)
(This used to be ctdb commit b49069aac0c14e5a02be843247930c197d620a81)

ctdb/common/ctdb_daemon.c
ctdb/common/ctdb_util.c
ctdb/include/ctdb_private.h

index 14019ea3f10cd412d8939764c064d99191e3c5ec..d784b059b85217411fe488853f9987b978e28179 100644 (file)
@@ -244,6 +244,30 @@ static void daemon_request_shutdown(struct ctdb_client *client,
        _exit(0);
 }
 
+
+/*
+  send a fetch lock error reply to the client
+ */
+static void daemon_fetch_lock_error(struct ctdb_client *client,
+                                   struct ctdb_req_fetch_lock *f)
+{
+       struct ctdb_reply_fetch_lock r;
+
+       ZERO_STRUCT(r);
+       r.hdr.length       = sizeof(r);
+       r.hdr.ctdb_magic   = CTDB_MAGIC;
+       r.hdr.ctdb_version = CTDB_VERSION;
+       r.hdr.operation    = CTDB_REPLY_FETCH_LOCK;
+       r.hdr.reqid        = f->hdr.reqid;
+       r.state            = -1;
+       
+       /*
+        * Ignore the result, there's not much we can do anyway.
+        */
+       ctdb_queue_send(client->queue, (uint8_t *)&r.hdr,
+                       r.hdr.length);
+}
+
 /*
   called when the daemon gets a fetch lock request from a client
  */
@@ -257,21 +281,13 @@ static void daemon_request_fetch_lock(struct ctdb_client *client,
 
        ctdb_db = find_ctdb_db(client->ctdb, f->db_id);
        if (ctdb_db == NULL) {
-               struct ctdb_reply_fetch_lock r;
-
-               ZERO_STRUCT(r);
-               r.hdr.length       = sizeof(r);
-               r.hdr.ctdb_magic   = CTDB_MAGIC;
-               r.hdr.ctdb_version = CTDB_VERSION;
-               r.hdr.operation    = CTDB_REPLY_FETCH_LOCK;
-               r.hdr.reqid        = f->hdr.reqid;
-               r.state            = -1;
-
-               /*
-                * Ignore the result, there's not much we can do anyway.
-                */
-               ctdb_queue_send(client->queue, (uint8_t *)&r.hdr,
-                               r.hdr.length);
+               daemon_fetch_lock_error(client, f);
+               return;
+       }
+
+       if (!ctdb_validate_vnn(client->ctdb, f->header.dmaster)) {
+               DEBUG(0,(__location__ " Invalid dmaster %u\n", f->header.dmaster));
+               daemon_fetch_lock_error(client, f);
                return;
        }
 
index e824e098e56cea4ef749f852cb73bb0d6fd025b7..1c6a571d8ee9296f88bc19492e5d9719400cfa61 100644 (file)
@@ -102,3 +102,4 @@ uint32_t ctdb_hash(const TDB_DATA *key)
 
        return (1103515243 * value + 12345);  
 }
+
index 7b069e1331e4adcd8652b23a04d16309ff514291..0aa1a6b6960442f0134ca6b67ee4cda4486f4341 100644 (file)
@@ -50,6 +50,11 @@ struct ctdb_address {
        int port;
 };
 
+/*
+  check a vnn is valid
+ */
+#define ctdb_validate_vnn(ctdb, vnn) (((uint32_t)(vnn)) < (ctdb)->num_nodes)
+
 
 /* called from the queue code when a packet comes in. Called with data==NULL
    on error */