Fix null-response NPE in outgoing MMS

Fixes #2839
Closes #2840

// FREEBIE
This commit is contained in:
Jake McGinty 2015-03-31 10:41:23 -07:00 committed by Moxie Marlinspike
parent e70298e624
commit c04b675a1a
3 changed files with 11 additions and 3 deletions

View File

@ -20,6 +20,7 @@ import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.Uri;
import android.support.annotation.NonNull;
import android.util.Log;
import org.apache.http.Header;
@ -70,7 +71,7 @@ public class OutgoingLegacyMmsConnection extends LegacyMmsConnection implements
}
@Override
public SendConf send(byte[] pduBytes) throws UndeliverableMessageException {
public SendConf send(@NonNull byte[] pduBytes) throws UndeliverableMessageException {
try {
MmsRadio radio = MmsRadio.getInstance(context);

View File

@ -21,6 +21,7 @@ import android.content.Context;
import android.content.Intent;
import android.os.Build.VERSION;
import android.os.Build.VERSION_CODES;
import android.support.annotation.NonNull;
import android.telephony.SmsManager;
import android.util.Log;
@ -57,7 +58,7 @@ public class OutgoingLollipopMmsConnection extends LollipopMmsConnection impleme
@Override
@TargetApi(VERSION_CODES.LOLLIPOP)
public synchronized SendConf send(byte[] pduBytes) throws UndeliverableMessageException {
public synchronized SendConf send(@NonNull byte[] pduBytes) throws UndeliverableMessageException {
beginTransaction();
try {
MmsBodyProvider.Pointer pointer = MmsBodyProvider.makeTemporaryPointer(getContext());
@ -74,6 +75,10 @@ public class OutgoingLollipopMmsConnection extends LollipopMmsConnection impleme
Log.w(TAG, "MMS broadcast received and processed.");
pointer.close();
if (response == null) {
throw new UndeliverableMessageException("Null response.");
}
return (SendConf) new PduParser(response).parse();
} catch (IOException | TimeoutException e) {
throw new UndeliverableMessageException(e);

View File

@ -1,9 +1,11 @@
package org.thoughtcrime.securesms.mms;
import android.support.annotation.NonNull;
import org.thoughtcrime.securesms.transport.UndeliverableMessageException;
import ws.com.google.android.mms.pdu.SendConf;
public interface OutgoingMmsConnection {
SendConf send(byte[] pduBytes) throws UndeliverableMessageException;
SendConf send(@NonNull byte[] pduBytes) throws UndeliverableMessageException;
}