diff --git a/common/sdp-xml.c b/common/sdp-xml.c index 0403dcd..5f314b7 100644 --- a/common/sdp-xml.c +++ b/common/sdp-xml.c @@ -239,9 +239,7 @@ static void convert_raw_data_to_xml(sdp_data_t *value, int indent_level, hex = 0; for (i = 0; i < length; i++) { - if (value->val.str[i] == '\0') - break; - if (!isprint(value->val.str[i])) { + if (!isprint(value->val.str[i]) && value->val.str[i] != '\0') { hex = 1; break; } @@ -250,7 +248,8 @@ static void convert_raw_data_to_xml(sdp_data_t *value, int indent_level, if ((value->val.str[i] == '<') || (value->val.str[i] == '>') || (value->val.str[i] == '"') || - (value->val.str[i] == '&')) + (value->val.str[i] == '&') || + (value->val.str[i] == '\0')) num_chars_to_escape++; } @@ -304,7 +303,13 @@ static void convert_raw_data_to_xml(sdp_data_t *value, int indent_level, strBuf[j++] = 'o'; strBuf[j++] = 't'; } - else { + else if (value->val.str[i] == '\0') { + strBuf[j++] = '&'; + strBuf[j++] = '#'; + strBuf[j++] = '0'; + strBuf[j++] = '0'; + strBuf[j++] = ';'; + } else { strBuf[j++] = value->val.str[i]; } }