[Opensrf-commits] r1321 - trunk/src/libopensrf

svn at svn.open-ils.org svn at svn.open-ils.org
Thu May 15 16:46:19 EDT 2008


Author: erickson
Date: 2008-05-15 16:46:15 -0400 (Thu, 15 May 2008)
New Revision: 1321

Modified:
   trunk/src/libopensrf/transport_message.c
Log:
Patch from Scott McKellar:

This patch tweaks the jid_get_* functions, which copy various
fragments of an jabber id into a buffer supplied by the caller.

If these functions don't find the fragments they're looking for, they
now return an empty string in the buffer.  Earlier they would leave
the buffer unchanged, leaving it to the calling code to initialize
the buffer.



Modified: trunk/src/libopensrf/transport_message.c
===================================================================
--- trunk/src/libopensrf/transport_message.c	2008-05-15 13:36:32 UTC (rev 1320)
+++ trunk/src/libopensrf/transport_message.c	2008-05-15 20:46:15 UTC (rev 1321)
@@ -331,6 +331,8 @@
 
 	if( jid == NULL || buf == NULL || size <= 0 ) { return; }
 
+	buf[ 0 ] = '\0';
+	
 	/* find the @ and return whatever is in front of it */
 	int len = strlen( jid );
 	int i;
@@ -360,6 +362,8 @@
 		memcpy( buf, start, len );
 		buf[ len ] = '\0';
 	}
+	else
+		buf[ 0 ] = '\0';
 }
 
 void jid_get_domain( const char* jid, char buf[], int size ) {
@@ -384,6 +388,8 @@
 		memcpy( buf, jid + index1, dlen );
 		buf[dlen] = '\0'; // memcpy doesn't provide the nul
 	}
+	else
+		buf[ 0 ] = '\0';
 }
 
 void set_msg_error( transport_message* msg, const char* type, int err_code ) {



More information about the opensrf-commits mailing list