--- addressbook/conduit/address-conduit.c~	2005-06-25 11:45:04.000000000 -0400
+++ addressbook/conduit/address-conduit.c	2005-06-25 13:51:01.000000000 -0400
@@ -460,14 +460,19 @@
 {
 	static char buff[ 4096 ];
 	struct Address addr;
+	pi_buffer_t piBuf;
 
 	if (remote == NULL) {
 		sprintf (buff, "[NULL]");
 		return buff;
 	}
 
+	piBuf.data = remote->record;
+	piBuf.allocated = remote->length;
+	piBuf.used = remote->length;
+
 	memset (&addr, 0, sizeof (struct Address));
-	unpack_Address (&addr, remote->record, remote->length);
+	unpack_Address (&addr, &piBuf, address_v1);
 
 	g_snprintf (buff, 4096, "['%s' '%s' '%s']",
 		    addr.entry[entryLastname] ?
@@ -790,6 +795,7 @@
 {
 	GnomePilotRecord p;
 	static unsigned char record[0xffff];
+	pi_buffer_t piBuf;
 	
 	g_assert (local->addr != NULL );
 	
@@ -801,9 +807,16 @@
 	p.archived = local->local.archived;
 	p.secret = local->local.secret;
 
+	memset (&piBuf, 0, sizeof (piBuf));
+	pack_Address (local->addr, &piBuf, address_v1);
+
 	/* Generate pilot record structure */
+	if (piBuf.used > 0)
+		memcpy (record, piBuf.data, piBuf.used);
 	p.record = record;
-	p.length = pack_Address (local->addr, p.record, 0xffff);
+	p.length = piBuf.used;
+	if (piBuf.data)
+		free (piBuf.data);
 
 	return p;	
 }
@@ -841,7 +854,7 @@
 					NULL, NULL, &cat) > 0) {
 			local->local.category = cat;
 			memset (&addr, 0, sizeof (struct Address));
-			unpack_Address (&addr, buffer->data, 0xffff);
+			unpack_Address (&addr, buffer, address_v1);
 			for (i = 0; i < 5; i++) {
 				if (addr.entry[entryPhone1 + i])
 					local->addr->entry[entryPhone1 + i] = 
@@ -1014,10 +1027,16 @@
 	EContactField next_mail, next_home, next_work, next_fax;
 	EContactField next_other, next_main, next_pager, next_mobile;
 	int i;
+	pi_buffer_t piBuf;
 
 	g_return_val_if_fail(remote!=NULL,NULL);
 	memset (&address, 0, sizeof (struct Address));
-	unpack_Address (&address, remote->record, remote->length);
+
+	piBuf.data = remote->record;
+	piBuf.allocated = remote->length;
+	piBuf.used = remote->length;
+
+	unpack_Address (&address, &piBuf, address_v1);
 
 	if (in_contact == NULL)
 		contact = e_contact_new ();
@@ -1248,7 +1267,7 @@
 
 	buffer = pi_buffer_new (0xffff);
 	len = dlp_ReadAppBlock (dbi->pilot_socket, dbi->db_handle, 0,
-				0xffff, buffer);
+				-1, buffer);
 	
 	if (len < 0) {
 		WARN (_("Could not read pilot's Address application block"));
--- calendar/conduits/calendar/calendar-conduit.c~	2005-06-25 11:45:04.000000000 -0400
+++ calendar/conduits/calendar/calendar-conduit.c	2005-06-25 13:48:38.000000000 -0400
@@ -404,14 +404,20 @@
 {
 	static char buff[ 4096 ];
 	struct Appointment appt;
+	pi_buffer_t piBuf;
 
 	if (remote == NULL) {
 		sprintf (buff, "[NULL]");
 		return buff;
 	}
 
+
+	piBuf.data = remote->record;
+	piBuf.allocated = remote->length;
+	piBuf.used = remote->length;
+
 	memset (&appt, 0, sizeof (struct Appointment));
-	unpack_Appointment (&appt, remote->record, remote->length);
+	unpack_Appointment (&appt, &piBuf, datebook_v1);
 
 	g_snprintf (buff, 4096, "[%ld %ld '%s' '%s']",
 		    mktime (&appt.begin),
@@ -752,6 +758,7 @@
 {
 	GnomePilotRecord p;
 	static unsigned char record[0xffff];
+	pi_buffer_t piBuf;
 
 	g_assert (local->comp != NULL);
 	g_assert (local->appt != NULL );
@@ -762,9 +769,16 @@
 	p.archived = local->local.archived;
 	p.secret = local->local.secret;
 
+	memset (&piBuf, 0, sizeof (piBuf));
+	pack_Appointment (local->appt, &piBuf, datebook_v1);
+
 	/* Generate pilot record structure */
+	if (piBuf.used > 0)
+		memcpy (record, piBuf.data, piBuf.used);
 	p.record = record;
-	p.length = pack_Appointment (local->appt, p.record, 0xffff);
+	p.length = piBuf.used;
+	if (piBuf.data)
+		free (piBuf.data);
 
 	return p;	
 }
@@ -810,7 +824,7 @@
 					NULL, NULL, &cat) > 0) {
 			local->local.category = cat;
 			memset (&appt, 0, sizeof (struct Appointment));
-			unpack_Appointment (&appt, buffer->data, 0xffff);
+			unpack_Appointment (&appt, buffer, datebook_v1);
 			local->appt->alarm = appt.alarm;
 			local->appt->advance = appt.advance;
 			local->appt->advanceUnits = appt.advanceUnits;
@@ -1075,11 +1089,17 @@
 	GSList *edl = NULL;	
 	char *txt;
 	int pos, i;
+	pi_buffer_t piBuf;
 	
 	g_return_val_if_fail (remote != NULL, NULL);
 
+
+	piBuf.data = remote->record;
+	piBuf.allocated = remote->length;
+	piBuf.used = remote->length;
+
 	memset (&appt, 0, sizeof (struct Appointment));
-	unpack_Appointment (&appt, remote->record, remote->length);
+	unpack_Appointment (&appt, &piBuf, datebook_v1);
 
 	if (in_comp == NULL) {
 		comp = e_cal_component_new ();
@@ -1464,7 +1484,7 @@
 
 	buffer = pi_buffer_new (0xffff);
 	len = dlp_ReadAppBlock (dbi->pilot_socket, dbi->db_handle, 0,
-				0xffff, buffer);
+				-1, buffer);
 	
 	if (len < 0) {
 		WARN (_("Could not read pilot's Calendar application block"));
--- calendar/conduits/todo/todo-conduit.c~	2005-06-25 11:45:04.000000000 -0400
+++ calendar/conduits/todo/todo-conduit.c	2005-06-25 13:52:01.000000000 -0400
@@ -396,14 +396,19 @@
 {
 	static char buff[ 4096 ];
 	struct ToDo todo;
+	pi_buffer_t piBuf;
 
 	if (remote == NULL) {
 		sprintf (buff, "[NULL]");
 		return buff;
 	}
 
+	piBuf.data = remote->record;
+	piBuf.allocated = remote->length;
+	piBuf.used = remote->length;
+
 	memset (&todo, 0, sizeof (struct ToDo));
-	unpack_ToDo (&todo, remote->record, remote->length);
+	unpack_ToDo (&todo, &piBuf, todo_v1);
 
 	g_snprintf (buff, 4096, "[%d %ld %d %d '%s' '%s']",
 		    todo.indefinite,
@@ -546,6 +551,7 @@
 {
 	GnomePilotRecord p;
 	static unsigned char record[0xffff];
+	pi_buffer_t piBuf;
 
 	g_assert (local->comp != NULL);
 	g_assert (local->todo != NULL );
@@ -558,9 +564,16 @@
 	p.archived = local->local.archived;
 	p.secret = local->local.secret;
 
+	memset (&piBuf, 0, sizeof (piBuf));
+	pack_ToDo (local->todo, &piBuf, todo_v1);
+
 	/* Generate pilot record structure */
+	if (piBuf.used > 0)
+		memcpy (record, piBuf.data, piBuf.used);
 	p.record = record;
-	p.length = pack_ToDo (local->todo, p.record, 0xffff);
+	p.length = piBuf.used;
+	if (piBuf.data)
+		free (piBuf.data);
 
 	return p;	
 }
@@ -723,11 +736,16 @@
 	icaltimezone *utc_zone;
 	int priority;
 	char *txt;
+	pi_buffer_t piBuf;
 	
 	g_return_val_if_fail (remote != NULL, NULL);
 
+	piBuf.data = remote->record;
+	piBuf.allocated = remote->length;
+	piBuf.used = remote->length;
+
 	memset (&todo, 0, sizeof (struct ToDo));
-	unpack_ToDo (&todo, remote->record, remote->length);
+	unpack_ToDo (&todo, &piBuf, todo_v1);
 
 	utc_zone = icaltimezone_get_utc_timezone ();
 	now = icaltime_from_timet_with_zone (time (NULL), FALSE, 
@@ -955,7 +973,7 @@
 
 	buffer = pi_buffer_new (0xffff);
 	len = dlp_ReadAppBlock (dbi->pilot_socket, dbi->db_handle, 0,
-				0xffff, buffer);
+				-1, buffer);
 	
 	if (len < 0) {
 		WARN (_("Could not read pilot's ToDo application block"));
