Limit string field lengths for network/configuration objects
Change-Id: Ic375854bb697ee21a8fd7b15fccd0b0878212869
diff --git a/core/api/src/main/java/org/onosproject/net/config/basics/BasicUiTopoLayoutConfig.java b/core/api/src/main/java/org/onosproject/net/config/basics/BasicUiTopoLayoutConfig.java
index 4091f4e..92533a3 100644
--- a/core/api/src/main/java/org/onosproject/net/config/basics/BasicUiTopoLayoutConfig.java
+++ b/core/api/src/main/java/org/onosproject/net/config/basics/BasicUiTopoLayoutConfig.java
@@ -54,14 +54,23 @@
private static final String E_GEOMAP_ALREADY_SET =
"Can't set sprites when geomap is already set";
+ private static final int GEOMAP_MAX_LENGTH = 128;
+ private static final int SPRITES_MAX_LENGTH = 128;
+
@Override
public boolean isValid() {
if (object.has(GEOMAP) && object.has(SPRITES)) {
throw new InvalidFieldException(GEOMAP, E_GEOMAP_SPRITE);
}
+ // Validate the region and parent
+ region();
+ parent();
+
return hasOnlyFields(REGION, PARENT, GEOMAP, SPRITES, SCALE,
- OFFSET_X, OFFSET_Y);
+ OFFSET_X, OFFSET_Y)
+ && isValidLength(GEOMAP, GEOMAP_MAX_LENGTH)
+ && isValidLength(SPRITES, SPRITES_MAX_LENGTH);
}
@Override