coverity#1326731 Dm: Dubious method used

and

coverity#1326732 Dm: Dubious method used
coverity#1326734 Dm: Dubious method used
coverity#1326735 Dm: Dubious method used
coverity#1326739 Dm: Dubious method used

Change-Id: Id9d39decf7442b503079ebcfe8c881f0f2fe3eb3
This commit is contained in:
Caolán McNamara
2015-10-15 12:04:03 +01:00
parent aa8f218079
commit ab22d11279
4 changed files with 54 additions and 37 deletions

View File

@@ -755,9 +755,10 @@ public class LocalOfficeConnection
@Override
public void run() {
java.io.BufferedReader r = new java.io.BufferedReader(
new java.io.InputStreamReader(m_in) );
try {
java.io.BufferedReader r = new java.io.BufferedReader(
new java.io.InputStreamReader(m_in, "UTF-8") );
for ( ; ; ) {
String s = r.readLine();
if ( s == null ) {
@@ -765,6 +766,8 @@ public class LocalOfficeConnection
}
m_print.println(s);
}
} catch ( UnsupportedEncodingException e ) {
e.printStackTrace( System.err );
} catch ( java.io.IOException e ) {
e.printStackTrace( System.err );
}

View File

@@ -38,6 +38,7 @@ import java.io.File;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.io.UnsupportedEncodingException;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.Map;
@@ -333,9 +334,10 @@ public class Bootstrap {
new Thread( "Pipe: " + prefix) {
@Override
public void run() {
BufferedReader r = new BufferedReader(
new InputStreamReader( in ) );
try {
BufferedReader r = new BufferedReader(
new InputStreamReader(in, "UTF-8") );
for ( ; ; ) {
String s = r.readLine();
if ( s == null ) {
@@ -343,6 +345,8 @@ public class Bootstrap {
}
out.println( prefix + s );
}
} catch ( UnsupportedEncodingException e ) {
e.printStackTrace( System.err );
} catch ( java.io.IOException e ) {
e.printStackTrace( System.err );
}

View File

@@ -310,45 +310,53 @@ final class InstallationFinder {
StreamGobbler gobbler = new StreamGobbler( proc.getErrorStream() );
gobbler.start();
// read the which output from standard input stream
BufferedReader br = new BufferedReader(
new InputStreamReader( proc.getInputStream() ) );
String line = null;
try {
while ( ( line = br.readLine() ) != null ) {
if ( path == null ) {
// get the path from the which output
int index = line.lastIndexOf( SOFFICE );
if ( index != -1 ) {
int end = index + SOFFICE.length();
for ( int i = 0; i <= index; i++ ) {
File file = new File( line.substring( i, end ) );
try {
if ( file.exists() ) {
// resolve symlink
path = file.getCanonicalFile().getParent();
if ( path != null )
break;
// read the which output from standard input stream
BufferedReader br = new BufferedReader(
new InputStreamReader( proc.getInputStream(), "UTF-8" ) );
String line = null;
try {
while ( ( line = br.readLine() ) != null ) {
if ( path == null ) {
// get the path from the which output
int index = line.lastIndexOf( SOFFICE );
if ( index != -1 ) {
int end = index + SOFFICE.length();
for ( int i = 0; i <= index; i++ ) {
File file = new File( line.substring( i, end ) );
try {
if ( file.exists() ) {
// resolve symlink
path = file.getCanonicalFile().getParent();
if ( path != null )
break;
}
} catch ( SecurityException e ) {
return null;
}
} catch ( SecurityException e ) {
return null;
}
}
}
}
} catch ( IOException e ) {
// if an I/O exception is thrown, return <code>null</null>
System.err.println( "com.sun.star.lib.loader." +
"InstallationFinder::getPathFromWhich: " +
"reading which command output failed: " + e );
return null;
} finally {
try {
br.close();
} catch ( IOException e ) {
// closing standard input stream failed, ignore
}
}
} catch ( IOException e ) {
// if an I/O exception is thrown, return <code>null</null>
} catch ( UnsupportedEncodingException e ) {
// if an Encoding exception is thrown, return <code>null</null>
System.err.println( "com.sun.star.lib.loader." +
"InstallationFinder::getPathFromWhich: " +
"reading which command output failed: " + e );
"encoding failed: " + e );
return null;
} finally {
try {
br.close();
} catch ( IOException e ) {
// closing standard input stream failed, ignore
}
}
try {
@@ -563,12 +571,14 @@ final class InstallationFinder {
public void run() {
try {
BufferedReader br = new BufferedReader(
new InputStreamReader( m_istream ) );
new InputStreamReader( m_istream, "UTF-8" ) );
// read from input stream
while ( br.readLine() != null ) {
// don't handle line content
}
br.close();
} catch (UnsupportedEncodingException e) {
// cannot read from input stream
} catch ( IOException e ) {
// stop reading from input stream
}

View File

@@ -580,7 +580,7 @@ public class APIDescGetter extends DescGetter
entry.endsWith(sEndsWithCSVName))
{
InputStream input = this.getClass().getResourceAsStream("/" + entry);
csvFile = new BufferedReader(new InputStreamReader(input));
csvFile = new BufferedReader(new InputStreamReader(input, "UTF-8"));
break;
}
}
@@ -588,7 +588,7 @@ public class APIDescGetter extends DescGetter
else
{
InputStream in = con.getInputStream();
java.io.BufferedReader buf = new java.io.BufferedReader(new InputStreamReader(in));
java.io.BufferedReader buf = new java.io.BufferedReader(new InputStreamReader(in, "UTF-8"));
while (true)
{
String entry = buf.readLine();
@@ -602,7 +602,7 @@ public class APIDescGetter extends DescGetter
module +
"/" +
entry);
csvFile = new BufferedReader(new InputStreamReader(input));
csvFile = new BufferedReader(new InputStreamReader(input, "UTF-8"));
break;
}
}