Skip to content

Commit bdfe484

Browse files
committed
Merge pull request #1145 from garvankeeley/updater-safety
Add safety checks to updater. Maybe overkill, best to be safe.
2 parents 34f9d4d + 220b719 commit bdfe484

File tree

1 file changed

+16
-1
lines changed
  • android/src/main/java/org/mozilla/mozstumbler/client

1 file changed

+16
-1
lines changed

android/src/main/java/org/mozilla/mozstumbler/client/Updater.java

+16-1
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,25 @@ public void onPostExecute(IResponse response) {
6666
return;
6767
}
6868
Map<String, List<String>> headers = response.getHeaders();
69+
if (headers == null) {
70+
return;
71+
}
6972
Log.i(LOG_TAG, "Got headers: "+ headers.toString());
73+
if (headers.get("Location") == null) {
74+
return;
75+
}
7076
String locationUrl = headers.get("Location").get(0);
77+
if (locationUrl == null || locationUrl.length() < 1) {
78+
return;
79+
}
7180
String[] parts = locationUrl.split("/");
81+
if (parts.length < 2) {
82+
return;
83+
}
7284
String tag = parts[parts.length-1];
85+
if (tag.length() < 2) {
86+
return;
87+
}
7388
String latestVersion = tag.substring(1); // strip the 'v' from the beginning
7489

7590
String installedVersion = PackageUtils.getAppVersion(activity);
@@ -129,7 +144,7 @@ private void showUpdateDialog(final Context context,
129144
msg = String.format(msg, installedVersion, latestVersion);
130145

131146
if (installedVersion.startsWith("0.") &&
132-
latestVersion.startsWith("1.")) {
147+
latestVersion.startsWith("1.")) {
133148
// From 0.x to 1.0 and higher, the keystore changed
134149
msg += " " + context.getString(R.string.must_uninstall_to_update);
135150
}

0 commit comments

Comments
 (0)