From 8c2f58b8e91999e9c1cf10d95c7bbf5e0c6675e1 Mon Sep 17 00:00:00 2001 From: erickson Date: Thu, 15 May 2008 20:46:15 +0000 Subject: [PATCH 1/1] 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. git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@1321 9efc2488-bf62-4759-914b-345cdb29e865 --- src/libopensrf/transport_message.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/libopensrf/transport_message.c b/src/libopensrf/transport_message.c index c66df27..b23e317 100644 --- a/src/libopensrf/transport_message.c +++ b/src/libopensrf/transport_message.c @@ -331,6 +331,8 @@ void jid_get_username( const char* jid, char buf[], int size ) { 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 @@ void jid_get_resource( const char* jid, char buf[], int size) { 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 @@ void jid_get_domain( const char* jid, char buf[], int size ) { 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 ) { -- 2.43.2