RIC-851: Updated rmr to define messagetype
[ric-plt/lib/rmr.git] / src / rmr / common / src / wrapper.c
index 55cfe9e..63f5d8a 100644 (file)
@@ -32,7 +32,7 @@
 
 #include "../include/rmr.h"
 
-#define ADD_SEP        1
+#define ADD_SEP                1
 #define        NO_SEP          0
 
 /*
@@ -74,7 +74,7 @@ static int bang_on( char* target, char* src, int max ) {
        if( src && target ) {
                len = strlen( src );
                if( (rc = len <= max ? len : 0 ) > 0 ) {        // if it fits, add it.
-                       strcat( target, src );
+                       strncat( target, src, len );
                }
        }
 
@@ -84,8 +84,16 @@ static int bang_on( char* target, char* src, int max ) {
        return rc;
 }
 
+/*
+       Frees the string that was allocated and returned using rmr_get_consts()
+*/
+extern void rmr_free_consts( char* p) {
+       free(p);
+}
+
 /*
        Returns a set of json with the constants which are set in the header.
+       Caller must free the returned string using rmr_free_consts()
 */
 extern char* rmr_get_consts( ) {
        int             remain;                         // bytes remaining in wbuf
@@ -155,6 +163,6 @@ extern char* rmr_get_consts( ) {
        phrase = build_ival( "RMR_ERR_INITFAILED", RMR_ERR_INITFAILED, NO_SEP );
        remain -= bang_on( wbuf, phrase, remain );
 
-       strcat( wbuf, " }" );
+       strncat( wbuf, " }", remain );
        return strdup( wbuf );                  // chop unused space and return
 }