Browse code

core: cast to unsigned to make analyzers happy on index type

Daniel-Constantin Mierla authored on 03/09/2020 12:03:02
Showing 3 changed files
... ...
@@ -1448,7 +1448,7 @@ assign_stm:
1448 1448
 	| USER_AGENT_HEADER EQUAL error { yyerror("string value expected"); }
1449 1449
 	| URI_HOST_EXTRA_CHARS EQUAL STRING { _sr_uri_host_extra_chars=$3; }
1450 1450
 	| URI_HOST_EXTRA_CHARS EQUAL error { yyerror("string value expected"); }
1451
-	| HDR_NAME_EXTRA_CHARS EQUAL STRING { _ksr_hname_extra_chars=$3; }
1451
+	| HDR_NAME_EXTRA_CHARS EQUAL STRING { _ksr_hname_extra_chars=(unsigned char*)$3; }
1452 1452
 	| HDR_NAME_EXTRA_CHARS EQUAL error { yyerror("string value expected"); }
1453 1453
 	| REPLY_TO_VIA EQUAL NUMBER { reply_to_via=$3; }
1454 1454
 	| REPLY_TO_VIA EQUAL error { yyerror("boolean value expected"); }
... ...
@@ -216,7 +216,7 @@ extern str _ksr_xavp_via_params;
216 216
 extern str _ksr_xavp_via_fields;
217 217
 
218 218
 extern char *_sr_uri_host_extra_chars;
219
-extern char *_ksr_hname_extra_chars;
219
+extern unsigned char *_ksr_hname_extra_chars;
220 220
 
221 221
 extern char *ksr_stats_namesep;
222 222
 
... ...
@@ -154,17 +154,17 @@ static ksr_hdr_map_idx_t _ksr_hdr_map_idx[KSR_HDR_MAP_IDX_SIZE];
154 154
 /**
155 155
  * valid chars in header names
156 156
  */
157
-static char *_ksr_hname_chars_list = "0123456789AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz-._+~";
157
+static unsigned char *_ksr_hname_chars_list = (unsigned char*)"0123456789AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz-._+~";
158 158
 
159 159
 /**
160 160
  * additional valid chars in header names (core param)
161 161
  */
162
-char *_ksr_hname_extra_chars = "";
162
+unsigned char *_ksr_hname_extra_chars = (unsigned char*)"";
163 163
 
164 164
 /**
165 165
  * indexed valid chars in 256-array for 1-byte-index access check
166 166
  */
167
-static char _ksr_hname_chars_idx[KSR_HDR_MAP_IDX_SIZE];
167
+static unsigned char _ksr_hname_chars_idx[KSR_HDR_MAP_IDX_SIZE];
168 168
 
169 169
 
170 170
 /**
... ...
@@ -172,7 +172,7 @@ static char _ksr_hname_chars_idx[KSR_HDR_MAP_IDX_SIZE];
172 172
  */
173 173
 int ksr_hname_init_index(void)
174 174
 {
175
-	char c;
175
+	unsigned char c;
176 176
 	int i;
177 177
 
178 178
 	for(i=0; i<KSR_HDR_MAP_IDX_SIZE; i++) {
... ...
@@ -231,7 +231,7 @@ char *parse_sip_header_name(char* const begin, const char* const end,
231 231
 		hdr->type = HDR_ERROR_T;
232 232
 		return begin;
233 233
 	}
234
-	if(_ksr_hname_chars_idx[*begin] == 0) {
234
+	if(_ksr_hname_chars_idx[(unsigned char)(*begin)] == 0) {
235 235
 		LM_ERR("invalid start of header name for [%.*s]\n",
236 236
 				(int)(end-begin), begin);
237 237
 		hdr->type = HDR_ERROR_T;
... ...
@@ -241,7 +241,7 @@ char *parse_sip_header_name(char* const begin, const char* const end,
241 241
 	hdr->name.s = begin;
242 242
 
243 243
 	for(p=begin+1; p<end; p++) {
244
-		if(_ksr_hname_chars_idx[*p] == 0) {
244
+		if(_ksr_hname_chars_idx[(unsigned char)(*p)] == 0) {
245 245
 			/* char not allowed in header name */
246 246
 			break;
247 247
 		}
... ...
@@ -279,9 +279,9 @@ char *parse_sip_header_name(char* const begin, const char* const end,
279 279
 
280 280
 done:
281 281
 	/* lookup header type */
282
-	if(_ksr_hdr_map_idx[hdr->name.s[0]].idxs >= 0) {
283
-		for(i = _ksr_hdr_map_idx[hdr->name.s[0]].idxs;
284
-					i <= _ksr_hdr_map_idx[hdr->name.s[0]].idxe; i++) {
282
+	if(_ksr_hdr_map_idx[(unsigned char)(hdr->name.s[0])].idxs >= 0) {
283
+		for(i = _ksr_hdr_map_idx[(unsigned char)(hdr->name.s[0])].idxs;
284
+					i <= _ksr_hdr_map_idx[(unsigned char)(hdr->name.s[0])].idxe; i++) {
285 285
 			if(hdr->name.len == _ksr_hdr_map[i].hname.len
286 286
 					&& strncasecmp(hdr->name.s, _ksr_hdr_map[i].hname.s,
287 287
 							hdr->name.len) == 0) {
... ...
@@ -308,4 +308,4 @@ char* parse_hname2(char* const begin, const char* const end, struct hdr_field* c
308 308
 char* parse_hname2_short(char* const begin, const char* const end, struct hdr_field* const hdr)
309 309
 {
310 310
 	return parse_sip_header_name(begin, end, hdr, 0);
311
-}
312 311
\ No newline at end of file
312
+}