Skip to content

Commit f474bc7

Browse files
committed
http/h2_stream.lua: Don't compare with 0x80000000
The literal 0x80000000 might have overflowed in lua 5.3 if lua was compiled with `-DLUA_INT_TYPE=LUA_INT_INT`. Related to #82
1 parent ea68db8 commit f474bc7

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

http/h2_stream.lua

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -598,7 +598,7 @@ function stream_methods:write_headers_frame(payload, end_stream, end_headers, pa
598598
end
599599
if weight or stream_dep then
600600
flags = bor(flags, 0x20)
601-
assert(stream_dep < 0x80000000)
601+
assert(stream_dep <= 0x7fffffff)
602602
local tmp = stream_dep
603603
if exclusive then
604604
tmp = bor(tmp, 0x80000000)
@@ -663,7 +663,7 @@ frame_handlers[frame_types.PRIORITY] = function(stream, flags, payload) -- luach
663663
end
664664

665665
function stream_methods:write_priority_frame(exclusive, stream_dep, weight, timeout, flush)
666-
assert(stream_dep < 0x80000000)
666+
assert(stream_dep <= 0x7fffffff)
667667
if self.id == nil then
668668
self:pick_id()
669669
end
@@ -1100,15 +1100,15 @@ function stream_methods:write_window_update_frame(inc, timeout, flush)
11001100
if self.id ~= 0 and self.state == "idle" then
11011101
h2_errors.PROTOCOL_ERROR([['WINDOW_UPDATE' frames not allowed in "idle" state]])
11021102
end
1103-
if inc >= 0x80000000 or inc <= 0 then
1103+
if inc > 0x7fffffff or inc <= 0 then
11041104
h2_errors.PROTOCOL_ERROR("invalid window update increment", true)
11051105
end
11061106
local payload = spack(">I4", inc)
11071107
return self:write_http2_frame(frame_types.WINDOW_UPDATE, flags, payload, timeout, flush)
11081108
end
11091109

11101110
function stream_methods:write_window_update(inc, timeout)
1111-
while inc >= 0x80000000 do
1111+
while inc > 0x7fffffff do
11121112
local ok, err, errno = self:write_window_update_frame(0x7fffffff, 0, "f")
11131113
if not ok then
11141114
return nil, err, errno

0 commit comments

Comments
 (0)