Skip to content

Commit 9870fc2

Browse files
authored
Fix SubmitPart vulnerabilities
1 parent 6416892 commit 9870fc2

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

lua/pac3/editor/server/wear.lua

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ local isfunction = isfunction
77
local ProtectedCall = ProtectedCall
88

99
pace.StreamQueue = pace.StreamQueue or {}
10+
pace.MaxStreamQueue = 32 -- Max queued outfits per player
1011

1112
timer.Create("pac_check_stream_queue", 0.1, 0, function()
1213
local item = table.remove(pace.StreamQueue)
@@ -294,18 +295,22 @@ end
294295

295296
-- Inserts the given part into the StreamQueue
296297
function pace.SubmitPart(data, filter, callback)
297-
if istable(data.part) then
298-
pac.dprint("queuing part %q from %s", data.part.self.Name, tostring(data.owner))
299-
table.insert(pace.StreamQueue, {
300-
data = data,
301-
filter = filter,
302-
callback = callback
303-
})
304-
305-
return "queue"
298+
if not (istable(data.part) and IsValid(data.owner)) then return end
299+
local owner = data.owner
300+
local count = 0
301+
for _, v in ipairs(pace.StreamQueue) do
302+
if v.data.owner == owner then
303+
if count == pace.MaxStreamQueue then return end
304+
count = count + 1
305+
end
306306
end
307307

308-
return pace.SubmitPartNow(data, filter)
308+
pac.dprint("queuing part %q from %s", data.part.self.Name, tostring(data.owner))
309+
table.insert(pace.StreamQueue, {
310+
data = data,
311+
filter = filter,
312+
callback = callback
313+
})
309314
end
310315

311316
-- Inserts the given part into the StreamQueue, and notifies when it completes
@@ -407,7 +412,7 @@ end)
407412
function pace.ClearOutfit(ply)
408413
local uid = pac.Hash(ply)
409414

410-
pace.SubmitPart({part = "__ALL__", uid = pac.Hash(ply), owner = ply})
415+
pace.RemovePart({part = "__ALL__", uid = pac.Hash(ply), owner = ply})
411416
pace.CallHook("RemoveOutfit", ply)
412417
end
413418

0 commit comments

Comments
 (0)