diff options
author | Abhishek Koneru <akoneru@redhat.com> | 2012-05-18 17:59:50 -0400 |
---|---|---|
committer | Ade Lee <alee@redhat.com> | 2012-05-24 23:09:10 -0400 |
commit | be23c86db27b7f66ca16a10ae3ef3f043d1d4b27 (patch) | |
tree | ba5ed1bbe24889b7d22278093ee66cffc780b42b /base/silent | |
parent | 9db76ed1d1f8969e93aaff320e49662f53688e2e (diff) | |
download | pki-be23c86db27b7f66ca16a10ae3ef3f043d1d4b27.tar.gz pki-be23c86db27b7f66ca16a10ae3ef3f043d1d4b27.tar.xz pki-be23c86db27b7f66ca16a10ae3ef3f043d1d4b27.zip |
Fixes for Coverity Defects of Category : FB.SBSC_USE_STRINGBUFFER_CONCATENATION --Remaining
Diffstat (limited to 'base/silent')
5 files changed, 44 insertions, 45 deletions
diff --git a/base/silent/src/com/netscape/pkisilent/argparser/ArgParser.java b/base/silent/src/com/netscape/pkisilent/argparser/ArgParser.java index 29c1c394d..0e3325005 100755 --- a/base/silent/src/com/netscape/pkisilent/argparser/ArgParser.java +++ b/base/silent/src/com/netscape/pkisilent/argparser/ArgParser.java @@ -2009,7 +2009,7 @@ public class ArgParser { s = "Usage: " + synopsisString + "\n"; s += "Options include:\n\n"; for (int i = 0; i < matchList.size(); i++) { - String optionInfo = ""; + StringBuffer optionInfo = new StringBuffer(); rec = matchList.get(i); if (rec.convertCode == 'h' && !helpOptionsEnabled) { continue; @@ -2021,33 +2021,33 @@ public class ArgParser { } } for (ndesc = rec.nameList; ndesc != null; ndesc = ndesc.next) { - optionInfo += ndesc.name; + optionInfo.append(ndesc.name); if (hasOneWordAlias && !ndesc.oneWord) { - optionInfo += " "; + optionInfo.append(" "); } if (ndesc.next != null) { - optionInfo += ","; + optionInfo.append(","); } } if (!hasOneWordAlias) { - optionInfo += " "; + optionInfo.append(" "); } if (rec.convertCode != 'v' && rec.convertCode != 'h') { if (rec.valueDesc != null) { - optionInfo += rec.valueDesc; + optionInfo.append(rec.valueDesc); } else { if (rec.rangeDesc != null) { - optionInfo += "<" + rec.valTypeName() + " " - + rec.rangeDesc + ">"; + optionInfo.append("<" + rec.valTypeName() + " " + + rec.rangeDesc + ">"); } else { - optionInfo += "<" + rec.valTypeName() + ">"; + optionInfo.append("<" + rec.valTypeName() + ">"); } } } if (rec.numValues > 1) { - optionInfo += "X" + rec.numValues; + optionInfo.append("X" + rec.numValues); } - s += optionInfo; + s += optionInfo.toString(); if (rec.helpMsg.length() > 0) { int pad = helpIndent - optionInfo.length(); if (pad < 2) { //s += '\n'; diff --git a/base/silent/src/com/netscape/pkisilent/common/CMSLDAP.java b/base/silent/src/com/netscape/pkisilent/common/CMSLDAP.java index cddb630da..ae9bc276e 100644 --- a/base/silent/src/com/netscape/pkisilent/common/CMSLDAP.java +++ b/base/silent/src/com/netscape/pkisilent/common/CMSLDAP.java @@ -215,19 +215,18 @@ public class CMSLDAP { } private String buildDNString(String s) { - - String val = ""; + StringBuffer val = new StringBuffer(); for (int i = 0; i < s.length(); i++) { if ((s.charAt(i) == ',') && (s.charAt(i + 1) == ' ')) { - val += ','; + val.append(','); i++; continue; } else { - val += s.charAt(i); + val.append(s.charAt(i)); } } - return val; + return val.toString(); } /** diff --git a/base/silent/src/com/netscape/pkisilent/common/ComCrypto.java b/base/silent/src/com/netscape/pkisilent/common/ComCrypto.java index e36966de1..2dacaabbf 100644 --- a/base/silent/src/com/netscape/pkisilent/common/ComCrypto.java +++ b/base/silent/src/com/netscape/pkisilent/common/ComCrypto.java @@ -291,11 +291,11 @@ public class ComCrypto { public String normalize(String s) { - String val = ""; + StringBuffer val = new StringBuffer(); for (int i = 0; i < s.length(); i++) { if ((s.charAt(i) == '\\') && (s.charAt(i + 1) == 'n')) { - val += '\n'; + val.append('\n'); i++; continue; } else if ((s.charAt(i) == '\\') && (s.charAt(i + 1) == 'r')) { @@ -304,9 +304,9 @@ public class ComCrypto { } else if (s.charAt(i) == '"') { continue; } - val += s.charAt(i); + val.append(s.charAt(i)); } - return val; + return val.toString(); } /** @@ -315,11 +315,11 @@ public class ComCrypto { public String normalizeForLDAP(String s) { - String val = ""; + StringBuffer val = new StringBuffer(); for (int i = 0; i < s.length(); i++) { if ((s.charAt(i) == '\\') && (s.charAt(i + 1) == 'n')) { - val += '\n' + " "; + val.append(System.getProperty("line.separator") + " "); i++; continue; } else if ((s.charAt(i) == '\\') && (s.charAt(i + 1) == 'r')) { @@ -328,9 +328,9 @@ public class ComCrypto { } else if (s.charAt(i) == '"') { continue; } - val += s.charAt(i); + val.append(s.charAt(i)); } - return val; + return val.toString(); } /** @@ -339,20 +339,20 @@ public class ComCrypto { public String pkcs7Convertcert(String s) { - String val = ""; + StringBuffer val = new StringBuffer(); int len = s.length(); for (int i = 0; i < len; i = i + 64) { if (i + 64 < len) { - val = val + s.substring(i, i + 64) + "\n"; + val.append(s.substring(i, i + 64)+System.getProperty("line.separator")); } else { - val = val + s.substring(i, len); + val.append(s.substring(i, len)); } } - return val; + return val.toString(); } /** diff --git a/base/silent/src/com/netscape/pkisilent/common/ServerInfo.java b/base/silent/src/com/netscape/pkisilent/common/ServerInfo.java index 7ff761720..706d4ccee 100644 --- a/base/silent/src/com/netscape/pkisilent/common/ServerInfo.java +++ b/base/silent/src/com/netscape/pkisilent/common/ServerInfo.java @@ -244,17 +244,17 @@ public class ServerInfo { private String stripSpace(String s) { - String val = ""; + StringBuffer val = new StringBuffer(); for (int i = 0; i < s.length(); i++) { if ((s.charAt(i) == ' ')) { i++; continue; } else { - val += s.charAt(i); + val.append(s.charAt(i)); } } - return val; + return val.toString(); } private void readAdminConfig() { diff --git a/base/silent/src/com/netscape/pkisilent/common/Utilities.java b/base/silent/src/com/netscape/pkisilent/common/Utilities.java index 22a0c3fcf..08c96e194 100644 --- a/base/silent/src/com/netscape/pkisilent/common/Utilities.java +++ b/base/silent/src/com/netscape/pkisilent/common/Utilities.java @@ -113,7 +113,7 @@ public class Utilities { return null; } - String val = ""; + StringBuffer val = new StringBuffer(); for (int i = 0; i < s.length(); i++) { if ((s.charAt(i) == '\\') && (s.charAt(i + 1) == 'n')) { @@ -125,9 +125,9 @@ public class Utilities { } else if (s.charAt(i) == '"') { continue; } - val += s.charAt(i); + val.append(s.charAt(i)); } - return val; + return val.toString(); } @@ -137,11 +137,11 @@ public class Utilities { return null; } - String val = ""; + StringBuffer val = new StringBuffer(); for (int i = 0; i < s.length(); i++) { if ((s.charAt(i) == '\\') && (s.charAt(i + 1) == 'n')) { - val += '\n'; + val.append(System.getProperty("line.separator")); i++; continue; } else if ((s.charAt(i) == '\\') && (s.charAt(i + 1) == 'r')) { @@ -150,9 +150,9 @@ public class Utilities { } else if (s.charAt(i) == '"') { continue; } - val += s.charAt(i); + val.append(s.charAt(i)); } - return val; + return val.toString(); } /* @@ -262,7 +262,7 @@ public class Utilities { * a binary array[] to a Ldap filter string */ public static String escapeBinaryData(byte data[]) { - String result = ""; + StringBuffer result = new StringBuffer(); for (int i = 0; i < data.length; i++) { String s = Integer.toHexString(0xff & data[i]); @@ -270,11 +270,11 @@ public class Utilities { if (s.length() == 1) { s = "0" + s; } - result = result + "\\" + s; + result.append("\\" + s); } - System.out.println("LDAP_FILTER=" + result); - return result; + System.out.println("LDAP_FILTER=" + result.toString()); + return result.toString(); } /* @@ -323,14 +323,14 @@ public class Utilities { X500Name dname = (X500Name) csn1.get(CertificateSubjectName.DN_NAME); - String pp = ""; + StringBuffer pp = new StringBuffer(); RDN[] rdns = dname.getNames(); for (int i = rdns.length - 1; i >= 0; i--) { - pp = pp + rdns[i] + "\n"; + pp.append(rdns[i] + System.getProperty("line.separator")); } - cr.subject = pp; + cr.subject = pp.toString(); } catch (Exception e) { System.out.println("ERROR: Exception when decoding certificate=" + e); |