Re: Broken SDP parsing?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, 2009-03-09 at 13:40 -0300, Luiz Augusto von Dentz wrote:
> Hi Bastien,
> 
> On Mon, Mar 9, 2009 at 12:25 PM, Bastien Nocera <hadess@xxxxxxxxxx> wrote:
> > On Mon, 2009-03-09 at 11:32 -0300, Luiz Augusto von Dentz wrote:
> > Problem was sdp_data_alloc() falling back to doing an strlen() on the
> > string, instead of taking its existing length into account. That would
> > break any strings with NULLs embedded.
> >
> > The attached patch fixes this. I'm not certain that making this public
> > is useful, but feel free to make it so if you feel it's needed.
> >
> > Cheers
> >
> 
> Sounds good to me, I will check with Marcel or Johan if they can get
> this changes upstream.

Apparently &#00; isn't an allowed character in XML, so the attached
patch just swaps it out for a space. Much easier.

Cheers
diff --git a/common/sdp-xml.c b/common/sdp-xml.c
index 0403dcd..c3d3934 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;
 			}
@@ -304,7 +302,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];
 				}
 			}

[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux