Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 7f36b2e

Browse files
committedNov 13, 2018
Throw an error if the delay parameter, when converted to milliseconds, would overflow a 32 bit signed integer.
1 parent 33eb1b6 commit 7f36b2e

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed
 

‎app.js

+9
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,15 @@ app.use('/delay', function(req, res) {
6464
res.send("Error: must specify t (for delay time) and key and event in the URL.");
6565
return;
6666
}
67+
var maxSupportedDelay = Math.pow(2,31) - 1;
68+
if ((delay * 60 * 1000) > maxSupportedDelay) {
69+
// setTimeout() uses a 32-bit signed integer for its delay parameter
70+
// A larger number causes setTimeout() to execute immediately, which
71+
// is likely not what the user would want.
72+
// Throw an explicit error if the passed delay time will exceed it.
73+
res.send("Error: Delay time cannot exceed " + (maxSupportedDelay / 60 / 1000) + " minutes.");
74+
return;
75+
}
6776

6877
// Fetch the values from the POST body
6978
var value1 = req.body.Value1;

0 commit comments

Comments
 (0)
Please sign in to comment.