disallow subsequent session-accept

This commit is contained in:
Daniel Gultsch 2019-06-17 09:51:49 +02:00
parent c1bdda0a9b
commit 782d889cc5

View file

@ -234,7 +234,6 @@ public class JingleConnection implements Transferable {
} else if (packet.isAction("session-accept")) {
returnResult = receiveAccept(packet);
} else if (packet.isAction("session-info")) {
returnResult = true;
Element checksum = packet.getChecksum();
Element file = checksum == null ? null : checksum.findChild("file");
Element hash = file == null ? null : file.findChild("hash", "urn:xmpp:hashes:2");
@ -378,6 +377,9 @@ public class JingleConnection implements Transferable {
this.initialTransport = content.hasSocks5Transport() ? Transport.SOCKS : Transport.IBB;
this.contentName = content.getAttribute("name");
this.transportId = content.getTransportId();
mXmppConnectionService.sendIqPacket(account, packet.generateResponse(IqPacket.TYPE.RESULT), null);
if (this.initialTransport == Transport.SOCKS) {
this.mergeCandidates(JingleCandidate.parse(content.socks5transport().getChildren()));
} else if (this.initialTransport == Transport.IBB) {
@ -392,7 +394,7 @@ public class JingleConnection implements Transferable {
return;
}
} else {
Log.d(Config.LOGTAG, "received block size =" + receivedBlockSize);
Log.d(Config.LOGTAG, "received block size was null");
this.sendCancel();
this.fail();
return;
@ -406,8 +408,6 @@ public class JingleConnection implements Transferable {
}
this.fileOffer = content.getFileOffer(this.ftVersion);
mXmppConnectionService.sendIqPacket(account, packet.generateResponse(IqPacket.TYPE.RESULT), null);
if (fileOffer != null) {
Element encrypted = fileOffer.findChild("encrypted", AxolotlService.PEP_PREFIX);
if (encrypted != null) {
@ -637,12 +637,17 @@ public class JingleConnection implements Transferable {
}
private boolean receiveAccept(JinglePacket packet) {
if (this.mJingleStatus != JINGLE_STATUS_INITIATED) {
Log.d(Config.LOGTAG,account.getJid().asBareJid()+": received out of order session-accept");
return false;
}
this.mJingleStatus = JINGLE_STATUS_ACCEPTED;
mXmppConnectionService.markMessage(message, Message.STATUS_UNSEND);
Content content = packet.getJingleContent();
if (content.hasSocks5Transport()) {
mergeCandidates(JingleCandidate.parse(content.socks5transport().getChildren()));
this.connectNextCandidate();
return true;
} else if (content.hasIbbTransport()) {
String receivedBlockSize = packet.getJingleContent().ibbTransport().getAttribute("block-size");
if (receivedBlockSize != null) {
@ -653,8 +658,10 @@ public class JingleConnection implements Transferable {
}
this.transport = new JingleInbandTransport(this, this.transportId, this.ibbBlockSize);
this.transport.connect(onIbbTransportConnected);
return true;
} else {
return false;
}
return true;
}
private boolean receiveTransportInfo(JinglePacket packet) {
@ -1110,13 +1117,7 @@ public class JingleConnection implements Transferable {
public boolean start() {
if (account.getStatus() == Account.State.ONLINE) {
if (mJingleStatus == JINGLE_STATUS_INITIATED) {
new Thread(new Runnable() {
@Override
public void run() {
sendAccept();
}
}).start();
new Thread(this::sendAccept).start();
}
return true;
} else {