Rev 731: catch internal traversal errors in http://samba.org/~tridge/ctdb

tridge at samba.org tridge at samba.org
Mon Jan 7 03:08:25 GMT 2008


------------------------------------------------------------
revno: 731
revision-id:tridge at samba.org-20080107030825-9zqjnp6fe3z4y814
parent: tridge at samba.org-20080107030701-l8awuh0wr4lcpbgt
committer: Andrew Tridgell <tridge at samba.org>
branch nick: tridge.stable
timestamp: Mon 2008-01-07 14:08:25 +1100
message:
  catch internal traversal errors
modified:
  server/ctdb_recoverd.c         recoverd.c-20070503213540-bvxuyd9jm1f7ig90-1
=== modified file 'server/ctdb_recoverd.c'
--- a/server/ctdb_recoverd.c	2008-01-06 02:24:55 +0000
+++ b/server/ctdb_recoverd.c	2008-01-07 03:08:25 +0000
@@ -542,7 +542,7 @@
 			struct ctdb_ltdb_header header;
 			if (existing.dsize < sizeof(struct ctdb_ltdb_header)) {
 				DEBUG(0,(__location__ " Bad record size %u from node %u\n", 
-					 existing.dsize, srcnode));
+					 (unsigned)existing.dsize, srcnode));
 				free(existing.dptr);
 				talloc_free(tmp_ctx);
 				return -1;
@@ -898,6 +898,7 @@
 	struct ctdb_context *ctdb;
 	struct ctdb_control_pulldb_reply *recdata;
 	uint32_t len;
+	bool failed;
 };
 
 static int traverse_recdb(struct tdb_context *tdb, TDB_DATA key, TDB_DATA data, void *p)
@@ -917,10 +918,15 @@
 
 	/* add the record to the blob ready to send to the nodes */
 	rec = ctdb_marshall_record(params->recdata, 0, key, NULL, data);
+	if (rec == NULL) {
+		params->failed = true;
+		return -1;
+	}
 	params->recdata = talloc_realloc_size(NULL, params->recdata, rec->length + params->len);
 	if (params->recdata == NULL) {
 		DEBUG(0,(__location__ " Failed to expand recdata to %u (%u records)\n", 
 			 rec->length + params->len, params->recdata->count));
+		params->failed = true;
 		return -1;
 	}
 	params->recdata->count++;
@@ -949,12 +955,20 @@
 	params.ctdb = ctdb;
 	params.recdata = recdata;
 	params.len = offsetof(struct ctdb_control_pulldb_reply, data);
+	params.failed = false;
 
 	if (tdb_traverse_read(recdb->tdb, traverse_recdb, &params) == -1) {
 		DEBUG(0,(__location__ " Failed to traverse recdb database\n"));
+		talloc_free(params.recdata);
 		return -1;
 	}
 
+	if (params.failed) {
+		DEBUG(0,(__location__ " Failed to traverse recdb database\n"));
+		talloc_free(params.recdata);
+		return -1;		
+	}
+
 	recdata = params.recdata;
 
 	outdata.dptr = (void *)recdata;



More information about the samba-cvs mailing list