summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChen Congwu <congwu.chen@intel.com>2010-03-24 12:00:42 +0800
committerChen Congwu <congwu.chen@intel.com>2010-03-24 12:10:05 +0800
commit1077b831ecf4dcc7e780bc4d4ec0f7b4326ceb94 (patch)
treed4f5d948dd3aa16c03a83a635eae9c81daa45b7a
parent277d35dc82f814e86da26020a17eeea65f7d9634 (diff)
smltk+DevInf decoding: avoid a possible infinite loopcongwu
For DevInf 1.1 parsing, DevInf decoding will cause an infinite loop if there is an empty <PropName> tag (found from Nokia N900, Nokia 7210c): eg: <CTCap> <CTType>text/plain</CTType> <PropName/> </CTCap> buildDevInfProperty will return OK without further processing if encountering an empty tag (in this case <PropName>) and the caller buildDevInfCtCap will re-evaluate the tag without advancing the parser, the re-evaluation can only end if current tag is an end tag or an unknown tag, otherwize it will call buildDevInfProperty with exactly the same environment again.
-rwxr-xr-xsrc/syncml_tk/src/sml/xlt/all/xltdevinf.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/syncml_tk/src/sml/xlt/all/xltdevinf.c b/src/syncml_tk/src/sml/xlt/all/xltdevinf.c
index 28b2aea..5ad9e4c 100755
--- a/src/syncml_tk/src/sml/xlt/all/xltdevinf.c
+++ b/src/syncml_tk/src/sml/xlt/all/xltdevinf.c
@@ -651,7 +651,9 @@ static Ret_t buildDevInfProperty(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem, in
XltDecScannerPtr_t pScanner = pDecoder->scanner;
Ret_t rc;
- if (IS_EMPTY(pScanner->curtok)) {
+ /* Do not return immediately for <1.2 style, the outer loop ends only meeting an end tag
+ * which will lead to an infinite loop*/
+ if (datastoreLocal && IS_EMPTY(pScanner->curtok)) {
return SML_ERR_OK;
}
@@ -825,6 +827,7 @@ Ret_t buildDevInfCtcap(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem, Boolean_t da
rc = buildDevInfProperty(pDecoder, (VoidPtr_t)&pCtcap->data->prop,datastoreLocal);
if (rc==SML_ERR_OK)
continue; // re-evaluate current tag (tag that caused buildDevInfProperty() to end, either unknown or closing </CTCap>
+ // this means do not return SML_ERR_OK unless this is an unknow tag or closing </CTCcap>, otherwise it will trigger an infinite loop
}
break;