- Fix isprint() portability in sldns, uses unsigned int.

git-svn-id: file:///svn/unbound/trunk@3042 be551aaa-1e26-0410-a405-d3ace91eadb9
This commit is contained in:
Wouter Wijngaards 2014-01-17 14:45:14 +00:00
parent add11387d4
commit d4f5ca1523
2 changed files with 10 additions and 7 deletions

View file

@ -1,3 +1,6 @@
17 January 2014: Wouter
- Fix isprint() portability in sldns, uses unsigned int.
16 January 2014: Wouter 16 January 2014: Wouter
- fix #544: Fixed +i causes segfault when running with module conf - fix #544: Fixed +i causes segfault when running with module conf
"iterator". "iterator".

View file

@ -718,7 +718,7 @@ int sldns_wire2str_rdata_unknown_scan(uint8_t** d, size_t* dlen, char** s,
} }
/** print and escape one character for a domain dname */ /** print and escape one character for a domain dname */
static int dname_char_print(char** s, size_t* slen, char c) static int dname_char_print(char** s, size_t* slen, uint8_t c)
{ {
if(c == '.' || c == ';' || c == '(' || c == ')' || c == '\\') if(c == '.' || c == ';' || c == '(' || c == ')' || c == '\\')
return sldns_str_print(s, slen, "\\%c", c); return sldns_str_print(s, slen, "\\%c", c);
@ -726,7 +726,7 @@ static int dname_char_print(char** s, size_t* slen, char c)
return sldns_str_print(s, slen, "\\%03u", (unsigned)c); return sldns_str_print(s, slen, "\\%03u", (unsigned)c);
/* plain printout */ /* plain printout */
if(*slen) { if(*slen) {
**s = c; **s = (char)c;
(*s)++; (*s)++;
(*slen)--; (*slen)--;
} }
@ -788,7 +788,7 @@ int sldns_wire2str_dname_scan(uint8_t** d, size_t* dlen, char** s, size_t* slen,
else if(!in_buf && pos+labellen > pkt+pktlen) else if(!in_buf && pos+labellen > pkt+pktlen)
labellen = (uint8_t)(pkt + pktlen - pos); labellen = (uint8_t)(pkt + pktlen - pos);
for(i=0; i<(unsigned)labellen; i++) { for(i=0; i<(unsigned)labellen; i++) {
w += dname_char_print(s, slen, (char)(*pos++)); w += dname_char_print(s, slen, *pos++);
} }
if(in_buf) { if(in_buf) {
(*d) += labellen; (*d) += labellen;
@ -1060,13 +1060,13 @@ int sldns_wire2str_aaaa_scan(uint8_t** d, size_t* dl, char** s, size_t* sl)
} }
/** printout escaped TYPE_STR character */ /** printout escaped TYPE_STR character */
static int str_char_print(char** s, size_t* sl, char c) static int str_char_print(char** s, size_t* sl, uint8_t c)
{ {
if(isprint((int)c) || c == '\t') { if(isprint((int)c) || c == '\t') {
if(c == '\"' || c == '\\') if(c == '\"' || c == '\\')
return sldns_str_print(s, sl, "\\%c", c); return sldns_str_print(s, sl, "\\%c", c);
if(*sl) { if(*sl) {
**s = c; **s = (char)c;
(*s)++; (*s)++;
(*sl)--; (*sl)--;
} }
@ -1086,7 +1086,7 @@ int sldns_wire2str_str_scan(uint8_t** d, size_t* dl, char** s, size_t* sl)
(*dl)--; (*dl)--;
w += sldns_str_print(s, sl, "\""); w += sldns_str_print(s, sl, "\"");
for(i=0; i<len; i++) for(i=0; i<len; i++)
w += str_char_print(s, sl, (char)(*d)[i]); w += str_char_print(s, sl, (*d)[i]);
w += sldns_str_print(s, sl, "\""); w += sldns_str_print(s, sl, "\"");
(*d)+=len; (*d)+=len;
(*dl)-=len; (*dl)-=len;
@ -1610,7 +1610,7 @@ int sldns_wire2str_long_str_scan(uint8_t** d, size_t* dl, char** s, size_t* sl)
int w = 0; int w = 0;
w += sldns_str_print(s, sl, "\""); w += sldns_str_print(s, sl, "\"");
for(i=0; i<*dl; i++) for(i=0; i<*dl; i++)
w += str_char_print(s, sl, (char)(*d)[i]); w += str_char_print(s, sl, (*d)[i]);
w += sldns_str_print(s, sl, "\""); w += sldns_str_print(s, sl, "\"");
(*d)+=*dl; (*d)+=*dl;
(*dl)=0; (*dl)=0;