- Fix SDP parsing to XML when it contains NULLs

This commit is contained in:
Bastien Nocera 2009-03-06 01:06:07 +00:00
parent ebbc295ddf
commit 8c7cfddfd2
2 changed files with 47 additions and 1 deletions

View File

@ -0,0 +1,40 @@
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];
}
}

View File

@ -1,7 +1,7 @@
Summary: Bluetooth utilities Summary: Bluetooth utilities
Name: bluez Name: bluez
Version: 4.32 Version: 4.32
Release: 4%{?dist} Release: 5%{?dist}
License: GPLv2+ License: GPLv2+
Group: Applications/System Group: Applications/System
Source: http://www.kernel.org/pub/linux/bluetooth/%{name}-%{version}.tar.gz Source: http://www.kernel.org/pub/linux/bluetooth/%{name}-%{version}.tar.gz
@ -12,6 +12,8 @@ Patch1: bluez-utils-oui-usage.patch
# https://bugzilla.redhat.com/show_bug.cgi?id=450081 # https://bugzilla.redhat.com/show_bug.cgi?id=450081
# http://thread.gmane.org/gmane.linux.bluez.kernel/1687 # http://thread.gmane.org/gmane.linux.bluez.kernel/1687
Patch2: bluez-try-utf8-harder.patch Patch2: bluez-try-utf8-harder.patch
# http://thread.gmane.org/gmane.linux.bluez.kernel/1688
Patch3: bluez-sdp-xml-with-nulls.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
URL: http://www.bluez.org/ URL: http://www.bluez.org/
@ -99,6 +101,7 @@ use in Bluetooth applications.
%setup -q %setup -q
%patch1 -p0 -b .oui %patch1 -p0 -b .oui
%patch2 -p1 -b .non-utf8-name %patch2 -p1 -b .non-utf8-name
%patch3 -p1 -b .nulls-in-sdp-text
%build %build
%configure --enable-cups --enable-hid2hci --enable-dfutool --enable-tools --enable-bccmd --enable-gstreamer --enable-hidd --enable-pand --enable-dund %configure --enable-cups --enable-hid2hci --enable-dfutool --enable-tools --enable-bccmd --enable-gstreamer --enable-hidd --enable-pand --enable-dund
@ -191,6 +194,9 @@ fi
%{_libdir}/alsa-lib/*.so %{_libdir}/alsa-lib/*.so
%changelog %changelog
* Fri Mar 06 2009 - Bastien Nocera <bnocera@redhat.com> - 4.32-5
- Fix SDP parsing to XML when it contains NULLs
* Thu Mar 05 2009 - Bastien Nocera <bnocera@redhat.com> - 4.32-4 * Thu Mar 05 2009 - Bastien Nocera <bnocera@redhat.com> - 4.32-4
- Work-around broken devices that export their names in ISO-8859-1 - Work-around broken devices that export their names in ISO-8859-1
(#450081) (#450081)