[tor-commits] [onionoo/master] Don't store user-supplied array directly.
karsten at torproject.org
karsten at torproject.org
Mon Apr 14 13:29:24 UTC 2014
commit 9f62a8115e4b24b3551b33aa7271d7250100ca24
Author: Karsten Loesing <karsten.loesing at gmx.net>
Date: Thu Mar 20 10:42:13 2014 +0100
Don't store user-supplied array directly.
Found with SonarQube.
---
src/org/torproject/onionoo/ResponseBuilder.java | 20 ++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)
diff --git a/src/org/torproject/onionoo/ResponseBuilder.java b/src/org/torproject/onionoo/ResponseBuilder.java
index b0775b1..1412d88 100644
--- a/src/org/torproject/onionoo/ResponseBuilder.java
+++ b/src/org/torproject/onionoo/ResponseBuilder.java
@@ -305,7 +305,8 @@ public class ResponseBuilder {
this.running = running;
}
public void setSearch(String[] search) {
- this.search = search;
+ this.search = new String[search.length];
+ System.arraycopy(search, 0, this.search, 0, search.length);
}
public void setLookup(String lookup) {
this.lookup = lookup;
@@ -320,19 +321,26 @@ public class ResponseBuilder {
this.flag = flag;
}
public void setFirstSeenDays(int[] firstSeenDays) {
- this.firstSeenDays = firstSeenDays;
+ this.firstSeenDays = new int[firstSeenDays.length];
+ System.arraycopy(firstSeenDays, 0, this.firstSeenDays, 0,
+ firstSeenDays.length);
}
public void setLastSeenDays(int[] lastSeenDays) {
- this.lastSeenDays = lastSeenDays;
+ this.lastSeenDays = new int[lastSeenDays.length];
+ System.arraycopy(lastSeenDays, 0, this.lastSeenDays, 0,
+ lastSeenDays.length);
}
public void setContact(String[] contact) {
- this.contact = contact;
+ this.contact = new String[contact.length];
+ System.arraycopy(contact, 0, this.contact, 0, contact.length);
}
public void setFields(String[] fields) {
- this.fields = fields;
+ this.fields = new String[fields.length];
+ System.arraycopy(fields, 0, this.fields, 0, fields.length);
}
public void setOrder(String[] order) {
- this.order = order;
+ this.order = new String[order.length];
+ System.arraycopy(order, 0, this.order, 0, order.length);
}
public void setOffset(String offset) {
this.offset = offset;
More information about the tor-commits
mailing list