Skip to content

Commit

Permalink
Prevent int overflow causing infinite loop in buf resizing
Browse files Browse the repository at this point in the history
  • Loading branch information
HParker authored and jhawthorn committed May 26, 2022
1 parent 8971009 commit e8de283
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions ext/yajl/yajl_buf.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,10 @@ yajl_buf_state yajl_buf_ensure_available(yajl_buf buf, unsigned int want)

need = buf->len;

while (want >= (need - buf->used)) need <<= 1;
while (want >= (need - buf->used) && need > 0) need <<= 1;

// Check for overflow
if (need < buf->used) {
if (need < buf->used || need == 0) {
return yajl_buf_set_error(buf, yajl_buf_overflow);
}

Expand Down
2 changes: 1 addition & 1 deletion lib/yajl/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Yajl
VERSION = '1.4.2'
VERSION = '1.4.3'
end

0 comments on commit e8de283

Please sign in to comment.