prevent crashing if push requests include bad packageNames

F-Droid shouldn't crash if a push request includes a bad package name. This
just makes it silently ignore those push requests.  If its a debug build,
it will send a message to logcat.  I'm not sure this is best way to handle
this, but this is better than crashing the app.  This will make it harder
for repo operators to debug issues with push requests.
This commit is contained in:
Hans-Christoph Steiner 2016-09-28 21:59:54 +02:00
parent 5c9dd1a11e
commit b90cf7386c
3 changed files with 15 additions and 1 deletions

View File

@ -459,6 +459,11 @@ public class RepoUpdater {
if (RepoPushRequest.INSTALL.equals(repoPushRequest.request)) {
ContentResolver cr = context.getContentResolver();
App app = AppProvider.Helper.findByPackageName(cr, packageName);
if (app == null) {
Utils.debugLog(TAG, packageName + " not in local database, ignoring request to"
+ repoPushRequest.request);
continue;
}
int versionCode;
if (repoPushRequest.versionCode == null) {
versionCode = app.suggestedVersionCode;

View File

@ -148,6 +148,10 @@ public class InstallManagerService extends Service {
App app = intent.getParcelableExtra(EXTRA_APP);
Apk apk = intent.getParcelableExtra(EXTRA_APK);
if (app == null || apk == null) {
Utils.debugLog(TAG, "Intent had null EXTRA_APP and/or EXTRA_APK: " + intent);
return START_NOT_STICKY;
}
addToActive(urlString, app, apk);
NotificationCompat.Builder builder = createNotificationBuilder(urlString, apk);

View File

@ -24,6 +24,7 @@ import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import org.fdroid.fdroid.Utils;
import org.fdroid.fdroid.data.Apk;
/**
@ -41,6 +42,7 @@ import org.fdroid.fdroid.data.Apk;
* {@link InstallManagerService}.
*/
public class InstallerService extends IntentService {
public static final String TAG = "InstallerService";
private static final String ACTION_INSTALL = "org.fdroid.fdroid.installer.InstallerService.action.INSTALL";
private static final String ACTION_UNINSTALL = "org.fdroid.fdroid.installer.InstallerService.action.UNINSTALL";
@ -52,7 +54,10 @@ public class InstallerService extends IntentService {
@Override
protected void onHandleIntent(Intent intent) {
Apk apk = intent.getParcelableExtra(Installer.EXTRA_APK);
if (apk == null) {
Utils.debugLog(TAG, "ignoring intent with null EXTRA_APK: " + intent);
return;
}
Installer installer = InstallerFactory.create(this, apk);
if (ACTION_INSTALL.equals(intent.getAction())) {