Browse code

- the string values of AVPs are kept 0 terminated

Bogdan-Andrei Iancu authored on 07/11/2004 21:25:50
Showing 1 changed files
... ...
@@ -28,6 +28,7 @@
28 28
  * ---------
29 29
  *  2004-07-21  created (bogdan)
30 30
  *  2004-10-09  interface more flexibil - more function available (bogdan)
31
+ *  2004-11-07  AVP string values are kept 0 terminated (bogdan)
31 32
  */
32 33
 
33 34
 
... ...
@@ -85,11 +86,11 @@ int add_avp(unsigned short flags, int_str name, int_str val)
85 86
 	if (flags&AVP_NAME_STR) {
86 87
 		if (flags&AVP_VAL_STR)
87 88
 			len += sizeof(struct str_str_data)-sizeof(void*) + name.s->len
88
-				+ val.s->len;
89
+				+ (val.s->len+1);
89 90
 		else
90 91
 			len += sizeof(struct str_int_data)-sizeof(void*) + name.s->len;
91 92
 	} else if (flags&AVP_VAL_STR)
92
-			len += sizeof(str)-sizeof(void*) + val.s->len;
93
+			len += sizeof(str)-sizeof(void*) + (val.s->len+1);
93 94
 
94 95
 	avp = (struct usr_avp*)shm_malloc( len );
95 96
 	if (avp==0) {
... ...
@@ -123,6 +124,7 @@ int add_avp(unsigned short flags, int_str name, int_str val)
123 124
 			s->len = val.s->len;
124 125
 			s->s = (char*)s + sizeof(str);
125 126
 			memcpy( s->s, val.s->s , s->len);
127
+			s->s[s->len] = 0;
126 128
 			break;
127 129
 		case AVP_NAME_STR|AVP_VAL_STR:
128 130
 			/* avp type str, str value */
... ...
@@ -133,6 +135,7 @@ int add_avp(unsigned short flags, int_str name, int_str val)
133 135
 			ssd->val.len = val.s->len;
134 136
 			ssd->val.s = ssd->name.s + ssd->name.len;
135 137
 			memcpy( ssd->val.s , val.s->s, val.s->len);
138
+			ssd->val.s[ssd->val.len] = 0;
136 139
 			break;
137 140
 	}
138 141