aboutsummaryrefslogtreecommitdiffstats
path: root/build
diff options
context:
space:
mode:
authorRblSb <msrblsb@gmail.com>2021-08-29 22:08:50 +0300
committerRblSb <msrblsb@gmail.com>2021-08-29 22:08:50 +0300
commit6cb22fb04d83e0bc1046dd980736d97768928725 (patch)
treef9c4ca2ebb4d84e9c39e26945dcdd287d153e20a /build
parente2c76dece4ba9daf1dcce338026339c17c9bd6cd (diff)
Fix int32 overflow
closes #29
Diffstat (limited to 'build')
-rw-r--r--build/server.js19
1 files changed, 14 insertions, 5 deletions
diff --git a/build/server.js b/build/server.js
index 5f39892..28f6ff2 100644
--- a/build/server.js
+++ b/build/server.js
@@ -3646,15 +3646,17 @@ server_HttpServer.serveMedia = function(req,res,filePath) {
range = "bytes=0-";
}
var ranges = new EReg("[-=]","g").split(range);
- var start = Std.parseInt(ranges[1]);
- if(start == null) {
+ var start = parseFloat(ranges[1]);
+ if(server_Utils.isOutOfRange(start,0,videoSize - 1)) {
start = 0;
}
- var end = Std.parseInt(ranges[2]);
- if(end == null) {
+ var end = parseFloat(ranges[2]);
+ if(isNaN(end)) {
end = start + 5242880;
}
- end = Math.min(end,videoSize - 1) | 0;
+ if(server_Utils.isOutOfRange(end,start,videoSize - 1)) {
+ end = videoSize - 1;
+ }
res.setHeader("Content-Range","bytes " + start + "-" + end + "/" + videoSize);
res.setHeader("Content-Length","" + (end - start + 1));
res.statusCode = 206;
@@ -4802,6 +4804,13 @@ server_Utils.getLocalIp = function() {
}
return "127.0.0.1";
};
+server_Utils.isOutOfRange = function(value,min,max) {
+ if(!(value == null || isNaN(value) || value < min)) {
+ return value > max;
+ } else {
+ return true;
+ }
+};
server_Utils.sortedPush = function(ids,id) {
var _g_current = 0;
while(_g_current < ids.length) if(id < ids[_g_current++]) {
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage