summaryrefslogtreecommitdiffstats
path: root/base/util
diff options
context:
space:
mode:
authorAbhishek Koneru <akoneru@redhat.com>2012-05-18 17:59:50 -0400
committerAde Lee <alee@redhat.com>2012-05-24 23:09:10 -0400
commitbe23c86db27b7f66ca16a10ae3ef3f043d1d4b27 (patch)
treeba5ed1bbe24889b7d22278093ee66cffc780b42b /base/util
parent9db76ed1d1f8969e93aaff320e49662f53688e2e (diff)
downloadpki-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/util')
-rw-r--r--base/util/src/netscape/security/util/ObjectIdentifier.java11
-rw-r--r--base/util/src/netscape/security/x509/Attribute.java9
-rw-r--r--base/util/src/netscape/security/x509/CertificateChain.java6
-rw-r--r--base/util/src/netscape/security/x509/GeneralSubtrees.java6
-rw-r--r--base/util/src/netscape/security/x509/IPAddressName.java15
-rw-r--r--base/util/src/netscape/security/x509/PolicyQualifiers.java9
-rw-r--r--base/util/src/netscape/security/x509/SubjectDirAttributesExtension.java6
7 files changed, 35 insertions, 27 deletions
diff --git a/base/util/src/netscape/security/util/ObjectIdentifier.java b/base/util/src/netscape/security/util/ObjectIdentifier.java
index 99de73e0d..e8ac1b626 100644
--- a/base/util/src/netscape/security/util/ObjectIdentifier.java
+++ b/base/util/src/netscape/security/util/ObjectIdentifier.java
@@ -345,15 +345,16 @@ final public class ObjectIdentifier implements Serializable {
* will not be understood everywhere.
*/
public String toString() {
- String retval;
+ StringBuffer retval = new StringBuffer();
+
int i;
- for (i = 0, retval = ""; i < componentLen; i++) {
+ for (i = 0; i < componentLen; i++) {
if (i != 0)
- retval += ".";
- retval += components[i];
+ retval.append(".");
+ retval.append(components[i]);
}
- return retval;
+ return retval.toString();
}
/*
diff --git a/base/util/src/netscape/security/x509/Attribute.java b/base/util/src/netscape/security/x509/Attribute.java
index 6cc1bfa03..8c3fc1fbd 100644
--- a/base/util/src/netscape/security/x509/Attribute.java
+++ b/base/util/src/netscape/security/x509/Attribute.java
@@ -214,14 +214,15 @@ public final class Attribute implements Serializable, DerEncoder {
*/
public String toString() {
String theoid = "Attribute: " + oid + "\n";
- String values = "Values: ";
+ StringBuffer values = new StringBuffer();
+ values.append("Values: ");
Enumeration<String> n = valueSet.elements();
if (n.hasMoreElements()) {
- values += n.nextElement();
+ values.append(n.nextElement());
while (n.hasMoreElements())
- values += "," + n.nextElement();
+ values.append("," + n.nextElement());
}
- return theoid + values + "\n";
+ return theoid + values.toString() + "\n";
}
//========== PRIVATE METHODS ==================================
diff --git a/base/util/src/netscape/security/x509/CertificateChain.java b/base/util/src/netscape/security/x509/CertificateChain.java
index 346dcc740..1329217ac 100644
--- a/base/util/src/netscape/security/x509/CertificateChain.java
+++ b/base/util/src/netscape/security/x509/CertificateChain.java
@@ -123,13 +123,15 @@ public class CertificateChain implements Serializable {
* Converts the certificate chain to a readable string.
*/
public String toString() {
+
String s = "[\n";
if (mChain == null)
return "[empty]";
+ StringBuffer tempBuffer = new StringBuffer();
for (int i = 0; i < mChain.length; i++) {
- s += mChain[i].toString();
+ tempBuffer.append(mChain[i].toString());
}
- s += "]\n";
+ s += tempBuffer.toString() + "]\n";
return s;
}
diff --git a/base/util/src/netscape/security/x509/GeneralSubtrees.java b/base/util/src/netscape/security/x509/GeneralSubtrees.java
index 720b6b225..d24774ab4 100644
--- a/base/util/src/netscape/security/x509/GeneralSubtrees.java
+++ b/base/util/src/netscape/security/x509/GeneralSubtrees.java
@@ -75,15 +75,15 @@ public class GeneralSubtrees {
public String toPrint(int indent) {
- String s = "";
+ StringBuffer s = new StringBuffer();
GeneralSubtree element;
for (Enumeration<GeneralSubtree> e = trees.elements(); e.hasMoreElements();) {
element = e.nextElement();
- s = s + pp.indent(indent + 4) + element.toPrint(indent) + "\n";
+ s.append(pp.indent(indent + 4) + element.toPrint(indent) + System.getProperty("line.separator"));
}
- return (s);
+ return (s.toString());
}
/**
diff --git a/base/util/src/netscape/security/x509/IPAddressName.java b/base/util/src/netscape/security/x509/IPAddressName.java
index 1270f910d..4ff8b8a0c 100644
--- a/base/util/src/netscape/security/x509/IPAddressName.java
+++ b/base/util/src/netscape/security/x509/IPAddressName.java
@@ -142,24 +142,25 @@ public class IPAddressName implements GeneralNameInterface {
+ (address[1] & 0xff) + "."
+ (address[2] & 0xff) + "." + (address[3] & 0xff));
} else {
- String r = "IPAddress: " + Integer.toHexString(address[0] & 0xff);
+ StringBuffer r = new StringBuffer();
+ r.append("IPAddress: " + Integer.toHexString(address[0] & 0xff));
String hexString = Integer.toHexString(address[1] & 0xff);
if (hexString.length() == 1) {
- r = r + "0" + hexString;
+ r.append("0" + hexString);
} else {
- r += hexString;
+ r.append(hexString);
}
for (int i = 2; i < address.length;) {
- r += ":" + Integer.toHexString(address[i] & 0xff);
+ r.append(":" + Integer.toHexString(address[i] & 0xff));
hexString = Integer.toHexString(address[i + 1] & 0xff);
if (hexString.length() == 1) {
- r = r + "0" + hexString;
+ r.append("0" + hexString);
} else {
- r += hexString;
+ r.append(hexString);
}
i += 2;
}
- return r;
+ return r.toString();
}
}
}
diff --git a/base/util/src/netscape/security/x509/PolicyQualifiers.java b/base/util/src/netscape/security/x509/PolicyQualifiers.java
index 632dc89de..def90066e 100644
--- a/base/util/src/netscape/security/x509/PolicyQualifiers.java
+++ b/base/util/src/netscape/security/x509/PolicyQualifiers.java
@@ -78,14 +78,15 @@ public class PolicyQualifiers implements java.io.Serializable {
* Returns a printable representation of the CertificatePolicyId.
*/
public String toString() {
- String s = "PolicyQualifiers: [";
+ StringBuffer s = new StringBuffer();
+ s.append("PolicyQualifiers: [");
for (int i = 0; i < mInfo.size(); i++) {
PolicyQualifierInfo pq = mInfo.elementAt(i);
- s = s + pq.toString();
+ s.append(pq.toString());
}
- s = s + "]\n";
+ s.append("]\n");
- return (s);
+ return s.toString();
}
/**
diff --git a/base/util/src/netscape/security/x509/SubjectDirAttributesExtension.java b/base/util/src/netscape/security/x509/SubjectDirAttributesExtension.java
index 3414b81c6..42ef26aa9 100644
--- a/base/util/src/netscape/security/x509/SubjectDirAttributesExtension.java
+++ b/base/util/src/netscape/security/x509/SubjectDirAttributesExtension.java
@@ -197,14 +197,16 @@ public class SubjectDirAttributesExtension extends Extension
* Return user readable form of extension.
*/
public String toString() {
+
String s = super.toString() + "SubjectDirectoryAttributes:[\n";
Enumeration<Attribute> attrs = attrList.elements();
+ StringBuffer tempBuffer = new StringBuffer();
while (attrs.hasMoreElements()) {
Attribute attr = attrs.nextElement();
- s += attr.toString();
+ tempBuffer.append(attr.toString());
}
-
+ s += tempBuffer.toString();
return (s + "]\n");
}