jkeys089 / lua-resty-hmac

HMAC functions for ngx_lua and LuaJIT
160 stars 99 forks source link

hmac.lua:136: attempt to get length of local 's' (a nil value) #12

Closed sckn closed 5 years ago

sckn commented 5 years ago

Hi,

2018/12/17 14:08:49 [error] 618#618: *35 lua entry thread aborted: runtime error: /usr/local/openresty/site/lualib/resty/hmac.lua:136: attempt to get length of local 's' (a nil value)
stack traceback:
coroutine 0:
    /usr/local/openresty/site/lualib/resty/hmac.lua: in function 'update'
    /usr/local/openresty/site/lualib/resty/aws-signature.lua:33: in function 'get_derived_signing_key'
    /usr/local/openresty/site/lualib/resty/aws-signature.lua:90: in function 'get_authorization'
    /usr/local/openresty/site/lualib/resty/aws-signature.lua:125: in function 'aws_set_headers'
    /usr/local/openresty/site/lualib/resty/aws-signature.lua:133: in function 's3_set_headers'
    access_by_lua(default.conf:29):2: in function <access_by_lua(default.conf:29):1>, client: 172.17.0.1, server: localhost, request: "GET /dincer.png HTTP/1.1", host: "localhost:8000"
2018/12/17 14:08:49 [error] 618#618: *34 lua entry thread aborted: runtime error: /usr/local/openresty/site/lualib/resty/hmac.lua:136: attempt to get length of local 's' (a nil value)
stack traceback:
coroutine 0:
    /usr/local/openresty/site/lualib/resty/hmac.lua: in function 'update'
    /usr/local/openresty/site/lualib/resty/aws-signature.lua:33: in function 'get_derived_signing_key'
    /usr/local/openresty/site/lualib/resty/aws-signature.lua:90: in function 'get_authorization'
    /usr/local/openresty/site/lualib/resty/aws-signature.lua:125: in function 'aws_set_headers'
    /usr/local/openresty/site/lualib/resty/aws-signature.lua:133: in function 's3_set_headers'
    access_by_lua(default.conf:29):2: in function <access_by_lua(default.conf:29):1>, client: 172.17.0.1, server: localhost, request: "GET /favicon.ico HTTP/1.1", host: "localhost:8000", referrer: "http://localhost:8000/dincer.png"
jkeys089 commented 5 years ago

@sckn looks like an issue with the aws-signature code passing in a nil value.

sckn commented 5 years ago

@sckn looks like an issue with the aws-signature code passing in a nil value.

Hi, I thought like you and I am debugged code like this.

function _M.update(self, s)
    ngx.log(ngx.STDERR, "debug >>>>> " .. s )
    return C.HMAC_Update(self._ctx, s, #s) == 1
end

returned this result.

2018/12/17 14:46:23 [] 629#629: *36 [lua] hmac.lua:136: update(): debug >>>>> 20181217, client: 172.17.0.1, server: localhost, request: "GET /favicon.ico HTTP/1.1", host: "localhost:8000", referrer: "http://localhost:8000/dincer.jpg"

jkeys089 commented 5 years ago

@sckn hmmm, that is strange. If you can provide a minimal reproducer I will take a deeper look.