Prechádzať zdrojové kódy

lib/srdb1: dummy string for null values pointed to static buffer

- allow editing in upper layers, avoiding innaproriate access to a constant
Daniel-Constantin Mierla 10 rokov pred
rodič
commit
d83fee0a31
1 zmenil súbory, kde vykonal 3 pridanie a 0 odobranie
  1. 3 0
      lib/srdb1/db_val.c

+ 3 - 0
lib/srdb1/db_val.c

@@ -44,6 +44,7 @@ int db_str2val(const db_type_t _t, db_val_t* _v, const char* _s, const int _l,
 		const unsigned int _cpy)
 {
 	static str dummy_string = {"", 0};
+	static char dummy_string_buf[2];
 	
 	if (!_v) {
 		LM_ERR("invalid parameter value\n");
@@ -57,6 +58,8 @@ int db_str2val(const db_type_t _t, db_val_t* _v, const char* _s, const int _l,
 			 * string so that we do not crash when the NULL flag
 			 * is set but the module does not check it properly
 			 */
+		dummy_string_buf[0] = '\0';
+		dummy_string.s = dummy_string_buf;
 		VAL_STRING(_v) = dummy_string.s;
 		VAL_STR(_v) = dummy_string;
 		VAL_BLOB(_v) = dummy_string;