mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-22 03:52:06 +01:00
Fix integer overflow if no max resumption time
is specified by client and server. Fixes SMACK-653.
This commit is contained in:
parent
cca34fd872
commit
3b6891b0d0
1 changed files with 7 additions and 2 deletions
|
@ -1612,7 +1612,7 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
|
|||
throw new StreamManagementException.StreamManagementNotEnabledException();
|
||||
}
|
||||
// Remove the listener after max. 12 hours
|
||||
final int removeAfterSeconds = Math.min(getMaxSmResumptionTime() + 60, 12 * 60 * 60);
|
||||
final int removeAfterSeconds = Math.min(getMaxSmResumptionTime(), 12 * 60 * 60);
|
||||
schedule(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
@ -1703,8 +1703,13 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
|
|||
|
||||
/**
|
||||
* Get the maximum resumption time in seconds after which a managed stream can be resumed.
|
||||
* <p>
|
||||
* This method will return {@link Integer#MAX_VALUE} if neither the client nor the server specify a maximum
|
||||
* resumption time. Be aware of integer overflows when using this value, e.g. do not add arbitrary values to it
|
||||
* without checking for overflows before.
|
||||
* </p>
|
||||
*
|
||||
* @return the maximum resumption time in seconds.
|
||||
* @return the maximum resumption time in seconds or {@link Integer#MAX_VALUE} if none set.
|
||||
*/
|
||||
public int getMaxSmResumptionTime() {
|
||||
int clientResumptionTime = smClientMaxResumptionTime > 0 ? smClientMaxResumptionTime : Integer.MAX_VALUE;
|
||||
|
|
Loading…
Reference in a new issue