jprjr/lua-resty-exec

Reading data from journal

jurafa opened this issue · 1 comments

Hi.
I am trying to read large amount of data from journal using

journalctl  --no-pager -n 5000 -o json

Program sockexec ends with error:

ERROR: Connection 0: unable to read from client (Connection reset by peer)

Openresty logs this error:

2017/06/22 16:10:05 [error] 22583#0: *9972 lua entry thread aborted: runtime error: /usr/local/openresty/site/lualib/netstring.lua:13: attempt to perform arithmetic on a nil value
stack traceback:
coroutine 0:
        /usr/local/openresty/site/lualib/netstring.lua: in function '_decode'
        /usr/local/openresty/site/lualib/netstring.lua:65: in function 'decode'
        /usr/local/openresty/site/lualib/resty/exec.lua:128: in function 'prog'

If I read less than 1000 items it usually completes without errors.
Any suggestions?

jprjr commented

Looks like it was a bug in netstring module - basically, when I was reading in the length of the netstring, I was going out-of-bounds of the data available. I had checks to make sure the data after the netstring length property existed, but none to make sure the whole netstring length property existed.

Just issued a new version of netstring (1.0.4), it should be available on luarocks and in opm. That should fix this error