ReadOnly: fix bug writing incorrect amount of data in delegated record
authorRonnie Sahlberg <ronniesahlberg@gmail.com>
Fri, 28 Oct 2011 00:44:19 +0000 (11:44 +1100)
committerRonnie Sahlberg <ronniesahlberg@gmail.com>
Fri, 28 Oct 2011 00:44:19 +0000 (11:44 +1100)
Fix bug when ctdbd updates the local copy of a delegated record to write the correct
amount of data to the record.

server/ctdb_call.c

index 9fc8b339012a06b9853b94ccd77cb000930cf938..23d10b9210b4f39e132203f96852537b7dc560d0 100644 (file)
@@ -741,8 +741,14 @@ void ctdb_reply_call(struct ctdb_context *ctdb, struct ctdb_req_header *hdr)
                        goto finished_ro;
                }
 
+               if (c->datalen < sizeof(struct ctdb_ltdb_header)) {
+                       DEBUG(DEBUG_ERR,(__location__ " Got FETCH_WITH_HEADER reply with too little data: %d bytes\n", c->datalen));
+                       ctdb_ltdb_unlock(ctdb_db, key);
+                       goto finished_ro;
+               }
+
+               data.dsize = c->datalen - sizeof(struct ctdb_ltdb_header);
                data.dptr  = &c->data[sizeof(struct ctdb_ltdb_header)];
-               data.dsize = sizeof(struct ctdb_ltdb_header);
                ret = ctdb_ltdb_store(ctdb_db, key, header, data);
                if (ret != 0) {
                        DEBUG(DEBUG_ERR, ("Failed to store new record in ctdb_reply_call\n"));