]> source.dussan.org Git - nextcloud-server.git/commitdiff
Added max heartbeat interval to prevent integer overflow
authorVincent Petry <pvince81@owncloud.com>
Thu, 12 Jun 2014 16:41:19 +0000 (18:41 +0200)
committerVincent Petry <pvince81@owncloud.com>
Thu, 12 Jun 2014 16:41:19 +0000 (18:41 +0200)
When using big session timeout values, the interval value might
overflow and cause the setInterval() call to ping the server in a loop
without any delay.

This fix adds a maximum ping interval of 24 hours.

Forward port of 00ec5fc1935c946e846a8ff28491e5b5b017b3d7 from stable6.

core/js/js.js

index 1d5219eff12103bf2c45fc165f4f35c25ded5305..a8dd9ca889d34b6f5b74e4504807dc4c8eb4b147 100644 (file)
@@ -968,6 +968,8 @@ function initCore() {
         * time out
         */
        function initSessionHeartBeat(){
+               // max interval in seconds set to 24 hours
+               var maxInterval = 24 * 3600;
                // interval in seconds
                var interval = 900;
                if (oc_config.session_lifetime) {
@@ -977,6 +979,9 @@ function initCore() {
                if (interval < 60) {
                        interval = 60;
                }
+               if (interval > maxInterval) {
+                       interval = maxInterval;
+               }
                var url = OC.generateUrl('/heartbeat');
                setInterval(function(){
                        $.post(url);