summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorBastien Nocera <hadess@hadess.net>2009-03-13 15:30:21 +0000
committerJohan Hedberg <johan.hedberg@nokia.com>2009-03-13 15:08:36 -0300
commit7c62ddad46bef2b752523eaa9157633e37dca140 (patch)
tree2c350b5d586bd583615910712a0a8108667dcc62 /common
parenteb101261ee8d43dd3a1bfaa982a3336cd8dfa020 (diff)
Don't truncate strings with embedded NULLs
Instead, replace the NULLs by spaces so we don't lose data when converting a device's SDP record to XML.
Diffstat (limited to 'common')
-rw-r--r--common/sdp-xml.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/common/sdp-xml.c b/common/sdp-xml.c
index 0403dcdd..608de769 100644
--- a/common/sdp-xml.c
+++ b/common/sdp-xml.c
@@ -239,9 +239,8 @@ 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;
}
@@ -304,7 +303,9 @@ 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++] = ' ';
+ } else {
strBuf[j++] = value->val.str[i];
}
}