Igalia / pflua

Packet filtering in Lua
Other
313 stars 39 forks source link

Length hoisting not working as well as it could #189

Closed wingo closed 9 years ago

wingo commented 9 years ago

Consider:

$ ./env tools/pflua-compile 'ip and greater 100'
local cast = require("ffi").cast
return function(P,length)
   if length < 14 then return false end
   if cast("uint16_t*", P+12)[0] ~= 8 then return false end
   return length >= 100
end

The >= 100 length check should be hoisted but it's not.

wingo commented 9 years ago

A smaller test case:

$ ./env tools/pflua-expand 'greater 10 and greater 100'
{ "if",
  { ">=",
    "len",
    10 },
  { ">=",
    "len",
    100 },
  { "fail" } }