From ae68e193fc99e0239d764d464c3f1c1f047f60fe Mon Sep 17 00:00:00 2001 From: sb Date: Mon, 28 Sep 2009 11:35:43 +0200 Subject: improve javaldx robustness when java executable prints additional stuff to stdout (as happens in some poor environments where java is a wrapper script that checks system patch levels etc. and prints advice to stdout...) --- jvmfwk/plugins/sunmajor/pluginlib/util.cxx | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/jvmfwk/plugins/sunmajor/pluginlib/util.cxx b/jvmfwk/plugins/sunmajor/pluginlib/util.cxx index a823d551af88..61edd8ebcaf4 100644 --- a/jvmfwk/plugins/sunmajor/pluginlib/util.cxx +++ b/jvmfwk/plugins/sunmajor/pluginlib/util.cxx @@ -127,7 +127,7 @@ extern VendorSupportMapEntry gVendorMap[]; bool getSDKInfoFromRegistry(vector & vecHome); bool getJREInfoFromRegistry(vector& vecJavaHome); -rtl::OUString decodeOutput(const rtl::OString& s); +bool decodeOutput(const rtl::OString& s, rtl::OUString* out); @@ -452,7 +452,9 @@ bool getJavaProps(const OUString & exePath, break; JFW_TRACE2(OString("[Java framework] line:\" ") + aLine + OString(" \".\n")); - OUString sLine = decodeOutput(aLine); + OUString sLine; + if (!decodeOutput(aLine, &sLine)) + continue; JFW_TRACE2(OString("[Java framework] line:\" ") + OString( CHAR_POINTER(sLine)) + OString(" \".\n")); sLine = sLine.trim(); @@ -486,8 +488,9 @@ bool getJavaProps(const OUString & exePath, readable strings. The strings are encoded as integer values separated by spaces. */ -rtl::OUString decodeOutput(const rtl::OString& s) +bool decodeOutput(const rtl::OString& s, rtl::OUString* out) { + OSL_ASSERT(out != 0); OUStringBuffer buff(512); sal_Int32 nIndex = 0; do @@ -495,14 +498,19 @@ rtl::OUString decodeOutput(const rtl::OString& s) OString aToken = s.getToken( 0, ' ', nIndex ); if (aToken.getLength()) { + for (sal_Int32 i = 0; i < aToken.getLength(); ++i) + { + if (aToken[i] < '0' || aToken[i] > '9') + return false; + } sal_Unicode value = (sal_Unicode)(aToken.toInt32()); buff.append(value); } } while (nIndex >= 0); - OUString sDecoded(buff.makeStringAndClear()); - JFW_TRACE2(sDecoded); - return sDecoded; + *out = buff.makeStringAndClear(); + JFW_TRACE2(*out); + return true; } -- cgit v1.2.3