aboutsummaryrefslogtreecommitdiffstats
path: root/sdkmanager
diff options
context:
space:
mode:
authorXavier Ducrohet <xav@android.com>2010-03-26 14:13:35 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2010-03-26 14:13:35 -0700
commit9d6c5d0ae9aa137094f2ce946f60d1a81a2661df (patch)
treecd4dba491be7f6fda38fef66c625d5d1cc21abb8 /sdkmanager
parent8d99c28017af1bd577f251cb8f37a0d0715744d3 (diff)
parent27d604b0dae72b0f5dfece494571a3dc6d0f0ed5 (diff)
downloadsdk-9d6c5d0ae9aa137094f2ce946f60d1a81a2661df.zip
sdk-9d6c5d0ae9aa137094f2ce946f60d1a81a2661df.tar.gz
sdk-9d6c5d0ae9aa137094f2ce946f60d1a81a2661df.tar.bz2
Merge "Prevent overflow in the AVD creation dialog"
Diffstat (limited to 'sdkmanager')
-rw-r--r--sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/widgets/AvdCreationDialog.java37
1 files changed, 24 insertions, 13 deletions
diff --git a/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/widgets/AvdCreationDialog.java b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/widgets/AvdCreationDialog.java
index 3734a42..01c5dcd 100644
--- a/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/widgets/AvdCreationDialog.java
+++ b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/widgets/AvdCreationDialog.java
@@ -742,19 +742,30 @@ final class AvdCreationDialog extends GridDialog {
} else {
String valueString = mSdCardSize.getText();
if (valueString.length() > 0) {
- int value = Integer.parseInt(valueString); // verifier makes this
- // unlikely to fail.
- switch (mSdCardSizeCombo.getSelectionIndex()) {
- case 0:
- value *= 1024;
- break;
- case 1:
- value *= 1024 * 1024;
- break;
- }
-
- if (value < 9 * 1024 * 1024) {
- error = "SD Card size must be at least 9MB";
+ // prevent overflow: no more than 999GB
+ // 10 digit for MiB, 13 for KiB
+ if (valueString.length() >= 10 +
+ (mSdCardSizeCombo.getSelectionIndex() == 0 ? 3 : 0)) {
+ error = "SD Card size is too big!";
+ } else {
+ try {
+ long value = Long.parseLong(valueString);
+
+ switch (mSdCardSizeCombo.getSelectionIndex()) {
+ case 0:
+ value *= 1024L;
+ break;
+ case 1:
+ value *= 1024L * 1024L;
+ break;
+ }
+
+ if (value < 9 * 1024 * 1024) {
+ error = "SD Card size must be at least 9MB";
+ }
+ } catch (NumberFormatException e) {
+ // will never happen thanks to the VerifyListener.
+ }
}
}
}