[OpenSRF-GIT] OpenSRF branch master updated. 6414c2527f6b6857d9f163bdba6f071b09f710a3

Evergreen Git git at git.evergreen-ils.org
Fri Aug 10 08:09:23 EDT 2018


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "OpenSRF".

The branch, master has been updated
       via  6414c2527f6b6857d9f163bdba6f071b09f710a3 (commit)
      from  71720f639e00d0e457bc8f967f8060b579bc2882 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 6414c2527f6b6857d9f163bdba6f071b09f710a3
Author: Mike Rylander <mrylander at gmail.com>
Date:   Fri Jul 7 15:22:21 2017 -0400

    LP#1702978: memcache Get methods use key as va_list format
    
    And, when a key (composed of, say, a username or barcode) has a % in it,
    bad things happen.  We will stop acting as if these are variadic functions
    now, and also update Evergreen so that it does not do that either.
    
    TODO: Make these actually non-variadic, but that breaks ABI.
    
    Signed-off-by: Mike Rylander <mrylander at gmail.com>
    Signed-off-by: Cesar Velez <cesar.velez at equinoxinitiative.org>
    Signed-off-by: Jason Stephenson <jason at sigio.com>

diff --git a/src/libopensrf/osrf_cache.c b/src/libopensrf/osrf_cache.c
index 08ac596..b6e9f1b 100644
--- a/src/libopensrf/osrf_cache.c
+++ b/src/libopensrf/osrf_cache.c
@@ -98,20 +98,19 @@ jsonObject* osrfCacheGetObject( const char* key, ... ) {
 	memcached_return rc;
 	jsonObject* obj = NULL;
 	if( key ) {
-		VA_LIST_TO_STRING(key);
-		char* clean_key = _clean_key( VA_BUF );
+		char* clean_key = _clean_key( key );
 		const char* data = (const char*) memcached_get(_osrfCache, clean_key, strlen(clean_key), &val_len, &flags, &rc);
 		free(clean_key);
 		if (rc != MEMCACHED_SUCCESS) {
 			osrfLogDebug(OSRF_LOG_MARK, "Failed to get key [%s] - %s",
-				VA_BUF, memcached_strerror(_osrfCache, rc));
+				key, memcached_strerror(_osrfCache, rc));
 		}
 		if( data ) {
-			osrfLogInternal( OSRF_LOG_MARK, "osrfCacheGetObject(): Returning object (key=%s): %s", VA_BUF, data);
+			osrfLogInternal( OSRF_LOG_MARK, "osrfCacheGetObject(): Returning object (key=%s): %s", key, data);
 			obj = jsonParse( data );
 			return obj;
 		}
-		osrfLogDebug(OSRF_LOG_MARK, "No cache data exists with key %s", VA_BUF);
+		osrfLogDebug(OSRF_LOG_MARK, "No cache data exists with key %s", key);
 	}
 	return NULL;
 }
@@ -121,16 +120,15 @@ char* osrfCacheGetString( const char* key, ... ) {
 	uint32_t flags;
 	memcached_return rc;
 	if( key ) {
-		VA_LIST_TO_STRING(key);
-		char* clean_key = _clean_key( VA_BUF );
+		char* clean_key = _clean_key( key );
 		char* data = (char*) memcached_get(_osrfCache, clean_key, strlen(clean_key), &val_len, &flags, &rc);
 		free(clean_key);
 		if (rc != MEMCACHED_SUCCESS) {
 			osrfLogDebug(OSRF_LOG_MARK, "Failed to get key [%s] - %s",
-				VA_BUF, memcached_strerror(_osrfCache, rc));
+				key, memcached_strerror(_osrfCache, rc));
 		}
-		osrfLogInternal( OSRF_LOG_MARK, "osrfCacheGetString(): Returning object (key=%s): %s", VA_BUF, data);
-		if(!data) osrfLogDebug(OSRF_LOG_MARK, "No cache data exists with key %s", VA_BUF);
+		osrfLogInternal( OSRF_LOG_MARK, "osrfCacheGetString(): Returning object (key=%s): %s", key, data);
+		if(!data) osrfLogDebug(OSRF_LOG_MARK, "No cache data exists with key %s", key);
 		return data;
 	}
 	return NULL;
@@ -140,13 +138,12 @@ char* osrfCacheGetString( const char* key, ... ) {
 int osrfCacheRemove( const char* key, ... ) {
 	memcached_return rc;
 	if( key ) {
-		VA_LIST_TO_STRING(key);
-		char* clean_key = _clean_key( VA_BUF );
+		char* clean_key = _clean_key( key );
 		rc = memcached_delete(_osrfCache, clean_key, strlen(clean_key), 0 );
 		free(clean_key);
 		if (rc != MEMCACHED_SUCCESS && rc != MEMCACHED_BUFFERED) {
 			osrfLogDebug(OSRF_LOG_MARK, "Failed to delete key [%s] - %s",
-				VA_BUF, memcached_strerror(_osrfCache, rc));
+				key, memcached_strerror(_osrfCache, rc));
 		}
 		return 0;
 	}
@@ -156,10 +153,9 @@ int osrfCacheRemove( const char* key, ... ) {
 
 int osrfCacheSetExpire( time_t seconds, const char* key, ... ) {
 	if( key ) {
-		VA_LIST_TO_STRING(key);
-		jsonObject* o = osrfCacheGetObject( VA_BUF );
-		//osrfCacheRemove(VA_BUF);
-		int rc = osrfCachePutObject( VA_BUF, o, seconds );
+		char* clean_key = _clean_key( key );
+		jsonObject* o = osrfCacheGetObject( clean_key );
+		int rc = osrfCachePutObject( clean_key, o, seconds );
 		jsonObjectFree(o);
 		return rc;
 	}

-----------------------------------------------------------------------

Summary of changes:
 src/libopensrf/osrf_cache.c |   30 +++++++++++++-----------------
 1 files changed, 13 insertions(+), 17 deletions(-)


hooks/post-receive
-- 
OpenSRF


More information about the opensrf-commits mailing list