Package: libwbxml2-0
Version: 0.9.2-6
Severity: normal

SyncML sometimes need to embed the device information into a message.
The device information is an own document. The actual package always
embeds the device information document with version 1.2. The
resulting document is simply wrong if the wrapping document is not
SyncML 1.2.

Several devices like all actual Nokia S40 models and several Sony-Ericsson
mobiles with the proprietary OS from Sony-Ericsson fail on such
documents. This means that the library does not work for more than 50
percent of the potentially usable mobiles. So the severity of this bug
is serious.

Please notice that reportbug downgraded the severity automatically
because I don't know the Debian policy manual section IDs.

The attached patch fixes the problem and sets the DevInf version
according to the version of the wrapping SyncML message.

-- System Information:
Debian Release: lenny/sid
  APT prefers unstable
  APT policy: (500, 'unstable'), (1, 'experimental')
Architecture: i386 (i686)

Kernel: Linux 2.6.25-2-686 (SMP w/1 CPU core)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash

Versions of packages libwbxml2-0 depends on:
ii  libc6                  2.7-11            GNU C Library: Shared libraries
ii  libexpat1              1.95.8-4          XML parsing C library - runtime li
ii  libpopt0               1.14-4            lib for parsing cmdline parameters
ii  zlib1g                 1:1.2.3.3.dfsg-12 compression library - runtime

libwbxml2-0 recommends no packages.

-- no debconf information
--- src/wbxml_tree_clb_xml.c.orig	2008-11-18 13:19:11.000000000 +0100
+++ src/wbxml_tree_clb_xml.c	2008-11-18 14:07:58.000000000 +0100
@@ -210,15 +210,41 @@
                     return;
                 }
 
-                /* Add doctype to give the XML parser a chance
-                 * SyncML 1.2 is downward compatible to older versions.
-                 */
-                if (!wbxml_buffer_insert_cstr(devinf_doc, "<!DOCTYPE DevInf PUBLIC '-//SYNCML//DTD DevInf 1.2//EN' 'http://www.openmobilealliance.org/tech/DTD/OMA-SyncML-Device_Information-DTD-1.2.dtd' >\n", 0))
-                {
-                    tree_ctx->error = WBXML_ERROR_NOT_ENOUGH_MEMORY;
-                    wbxml_buffer_destroy(devinf_doc);
-                    return;
-                }
+                /* Add doctype to give the XML parser a chance */
+		const WBXMLLangEntry *lang;
+		switch(tree_ctx->tree->lang->langID)
+		{
+			case WBXML_LANG_SYNCML_SYNCML10:
+				lang = wbxml_tables_get_table(WBXML_LANG_SYNCML_DEVINF10);
+				break;
+			case WBXML_LANG_SYNCML_SYNCML11:
+				lang = wbxml_tables_get_table(WBXML_LANG_SYNCML_DEVINF11);
+				break;
+			case WBXML_LANG_SYNCML_SYNCML12:
+				lang = wbxml_tables_get_table(WBXML_LANG_SYNCML_DEVINF12);
+				break;
+			default:
+				tree_ctx->error = WBXML_ERROR_UNKNOWN_XML_LANGUAGE;
+				return;
+		}
+		WBXMLBuffer *buffer = wbxml_buffer_create(NULL, 0, 0);
+		if (!buffer) {
+			tree_ctx->error = WBXML_ERROR_NOT_ENOUGH_MEMORY;
+			return;
+		}
+		/* DOCTYPE in reverse order */
+		if (!wbxml_buffer_insert_cstr(devinf_doc, "\">\n", 0) ||                     /* > */
+		    !wbxml_buffer_insert_cstr(devinf_doc, lang->publicID->xmlDTD, 0) ||      /* DTD */
+		    !wbxml_buffer_insert_cstr(devinf_doc, "\" \"", 0) ||                     /* DTD */
+		    !wbxml_buffer_insert_cstr(devinf_doc, lang->publicID->xmlPublicID, 0) || /* Public ID */
+		    !wbxml_buffer_insert_cstr(devinf_doc, " PUBLIC \"", 0) ||                /*  PUBLIC " */
+		    !wbxml_buffer_insert_cstr(devinf_doc, lang->publicID->xmlRootElt, 0) ||  /* Root Element */
+		    !wbxml_buffer_insert_cstr(devinf_doc, "<!DOCTYPE ", 0))                  /* <!DOCTYPE */
+		{
+			tree_ctx->error = WBXML_ERROR_ENCODER_APPEND_DATA;
+                	wbxml_buffer_destroy(devinf_doc);
+			return;
+		}
 
                 WBXML_DEBUG((WBXML_PARSER, "\t DevInf Doc : '%s'", wbxml_buffer_get_cstr(devinf_doc)));
 

Reply via email to