Module: kamailio
Branch: master
Commit: 99d96c4f5f82ca33fc6c0ccac383a3e41058405d
URL:
https://github.com/kamailio/kamailio/commit/99d96c4f5f82ca33fc6c0ccac383a3e…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2020-09-03T14:03:02+02:00
core: cast to unsigned to make analyzers happy on index type
---
Modified: src/core/cfg.y
Modified: src/core/globals.h
Modified: src/core/parser/parse_hname2.c
---
Diff:
https://github.com/kamailio/kamailio/commit/99d96c4f5f82ca33fc6c0ccac383a3e…
Patch:
https://github.com/kamailio/kamailio/commit/99d96c4f5f82ca33fc6c0ccac383a3e…
---
diff --git a/src/core/cfg.y b/src/core/cfg.y
index 6eccec29bd..d17540de72 100644
--- a/src/core/cfg.y
+++ b/src/core/cfg.y
@@ -1448,7 +1448,7 @@ assign_stm:
| USER_AGENT_HEADER EQUAL error { yyerror("string value expected"); }
| URI_HOST_EXTRA_CHARS EQUAL STRING { _sr_uri_host_extra_chars=$3; }
| URI_HOST_EXTRA_CHARS EQUAL error { yyerror("string value expected"); }
- | HDR_NAME_EXTRA_CHARS EQUAL STRING { _ksr_hname_extra_chars=$3; }
+ | HDR_NAME_EXTRA_CHARS EQUAL STRING { _ksr_hname_extra_chars=(unsigned char*)$3; }
| HDR_NAME_EXTRA_CHARS EQUAL error { yyerror("string value expected"); }
| REPLY_TO_VIA EQUAL NUMBER { reply_to_via=$3; }
| REPLY_TO_VIA EQUAL error { yyerror("boolean value expected"); }
diff --git a/src/core/globals.h b/src/core/globals.h
index 413e8f2374..ea16f3ae29 100644
--- a/src/core/globals.h
+++ b/src/core/globals.h
@@ -216,7 +216,7 @@ extern str _ksr_xavp_via_params;
extern str _ksr_xavp_via_fields;
extern char *_sr_uri_host_extra_chars;
-extern char *_ksr_hname_extra_chars;
+extern unsigned char *_ksr_hname_extra_chars;
extern char *ksr_stats_namesep;
diff --git a/src/core/parser/parse_hname2.c b/src/core/parser/parse_hname2.c
index a4fdca3e37..598008214a 100644
--- a/src/core/parser/parse_hname2.c
+++ b/src/core/parser/parse_hname2.c
@@ -154,17 +154,17 @@ static ksr_hdr_map_idx_t _ksr_hdr_map_idx[KSR_HDR_MAP_IDX_SIZE];
/**
* valid chars in header names
*/
-static char *_ksr_hname_chars_list =
"0123456789AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz-._+~";
+static unsigned char *_ksr_hname_chars_list = (unsigned
char*)"0123456789AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz-._+~";
/**
* additional valid chars in header names (core param)
*/
-char *_ksr_hname_extra_chars = "";
+unsigned char *_ksr_hname_extra_chars = (unsigned char*)"";
/**
* indexed valid chars in 256-array for 1-byte-index access check
*/
-static char _ksr_hname_chars_idx[KSR_HDR_MAP_IDX_SIZE];
+static unsigned char _ksr_hname_chars_idx[KSR_HDR_MAP_IDX_SIZE];
/**
@@ -172,7 +172,7 @@ static char _ksr_hname_chars_idx[KSR_HDR_MAP_IDX_SIZE];
*/
int ksr_hname_init_index(void)
{
- char c;
+ unsigned char c;
int i;
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,
hdr->type = HDR_ERROR_T;
return begin;
}
- if(_ksr_hname_chars_idx[*begin] == 0) {
+ if(_ksr_hname_chars_idx[(unsigned char)(*begin)] == 0) {
LM_ERR("invalid start of header name for [%.*s]\n",
(int)(end-begin), begin);
hdr->type = HDR_ERROR_T;
@@ -241,7 +241,7 @@ char *parse_sip_header_name(char* const begin, const char* const end,
hdr->name.s = begin;
for(p=begin+1; p<end; p++) {
- if(_ksr_hname_chars_idx[*p] == 0) {
+ if(_ksr_hname_chars_idx[(unsigned char)(*p)] == 0) {
/* char not allowed in header name */
break;
}
@@ -279,9 +279,9 @@ char *parse_sip_header_name(char* const begin, const char* const end,
done:
/* lookup header type */
- if(_ksr_hdr_map_idx[hdr->name.s[0]].idxs >= 0) {
- for(i = _ksr_hdr_map_idx[hdr->name.s[0]].idxs;
- i <= _ksr_hdr_map_idx[hdr->name.s[0]].idxe; i++) {
+ if(_ksr_hdr_map_idx[(unsigned char)(hdr->name.s[0])].idxs >= 0) {
+ for(i = _ksr_hdr_map_idx[(unsigned char)(hdr->name.s[0])].idxs;
+ i <= _ksr_hdr_map_idx[(unsigned char)(hdr->name.s[0])].idxe; i++) {
if(hdr->name.len == _ksr_hdr_map[i].hname.len
&& strncasecmp(hdr->name.s, _ksr_hdr_map[i].hname.s,
hdr->name.len) == 0) {
@@ -308,4 +308,4 @@ char* parse_hname2(char* const begin, const char* const end, struct
hdr_field* c
char* parse_hname2_short(char* const begin, const char* const end, struct hdr_field*
const hdr)
{
return parse_sip_header_name(begin, end, hdr, 0);
-}
\ No newline at end of file
+}