Skip to content

Commit

Permalink
Add size limit
Browse files Browse the repository at this point in the history
  • Loading branch information
Denneisk committed Mar 26, 2024
1 parent 37b7cbf commit 0b464db
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lua/entities/gmod_wire_expression2/core/string.lua
Original file line number Diff line number Diff line change
Expand Up @@ -508,11 +508,15 @@ local compress = util.Compress
local decompress = util.Decompress

e2function string compress(string plaintext)
self.prf = self.prf + #plaintext * 0.1
local len = #plaintext
if len > 32768 then return self:throw("Input string is too long!", "") end
self.prf = self.prf + len * 0.1
return compress(plaintext)
end

e2function string decompress(string compressed)
self.prf = self.prf + #compressed * 0.5
local len = #compressed
if len > 32768 then return self:throw("Input string is too long!", "") end
self.prf = self.prf + len * 0.5
return decompress(compressed) or self:throw("Invalid input for decompression!", "")
end

0 comments on commit 0b464db

Please sign in to comment.