From d4f5ca1523f093ecef15c6708d8489949328e3a2 Mon Sep 17 00:00:00 2001 From: Wouter Wijngaards Date: Fri, 17 Jan 2014 14:45:14 +0000 Subject: [PATCH] - Fix isprint() portability in sldns, uses unsigned int. git-svn-id: file:///svn/unbound/trunk@3042 be551aaa-1e26-0410-a405-d3ace91eadb9 --- doc/Changelog | 3 +++ ldns/wire2str.c | 14 +++++++------- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/doc/Changelog b/doc/Changelog index beb7451ad..5e6ab121d 100644 --- a/doc/Changelog +++ b/doc/Changelog @@ -1,3 +1,6 @@ +17 January 2014: Wouter + - Fix isprint() portability in sldns, uses unsigned int. + 16 January 2014: Wouter - fix #544: Fixed +i causes segfault when running with module conf "iterator". diff --git a/ldns/wire2str.c b/ldns/wire2str.c index 21cf5a63d..25ff58703 100644 --- a/ldns/wire2str.c +++ b/ldns/wire2str.c @@ -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 */ -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 == '\\') 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); /* plain printout */ if(*slen) { - **s = c; + **s = (char)c; (*s)++; (*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) labellen = (uint8_t)(pkt + pktlen - pos); 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) { (*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 */ -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(c == '\"' || c == '\\') return sldns_str_print(s, sl, "\\%c", c); if(*sl) { - **s = c; + **s = (char)c; (*s)++; (*sl)--; } @@ -1086,7 +1086,7 @@ int sldns_wire2str_str_scan(uint8_t** d, size_t* dl, char** s, size_t* sl) (*dl)--; w += sldns_str_print(s, sl, "\""); for(i=0; i