diff options
author | sb <sb@openoffice.org> | 2009-09-28 11:35:43 +0200 |
---|---|---|
committer | sb <sb@openoffice.org> | 2009-09-28 11:35:43 +0200 |
commit | ae68e193fc99e0239d764d464c3f1c1f047f60fe (patch) | |
tree | b203b14c58ee3170ccbdba8e044fcd7600407c26 /jvmfwk | |
parent | 3db62040dcaa470c0f69f904abfb82202f628005 (diff) |
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...)
Diffstat (limited to 'jvmfwk')
-rw-r--r-- | jvmfwk/plugins/sunmajor/pluginlib/util.cxx | 20 |
1 files 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<OUString> & vecHome); bool getJREInfoFromRegistry(vector<OUString>& 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; } |