Skip to content

Commit

Permalink
feat(utils) zero-fill RAND_bytes dst buffer
Browse files Browse the repository at this point in the history
  • Loading branch information
p0pr0ck5 committed Jun 22, 2017
1 parent a89c0c6 commit f18898c
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions kong/tools/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ local uuid = require "resty.jit-uuid"
local pl_stringx = require "pl.stringx"

local C = ffi.C
local ffi_fill = ffi.fill
local ffi_new = ffi.new
local ffi_str = ffi.string
local type = type
Expand Down Expand Up @@ -120,6 +121,7 @@ do

function _M.get_rand_bytes(n_bytes)
local buf = ffi_new(bytes_buf_t, n_bytes)
ffi_fill(buf, n_bytes, 0x0)

if C.RAND_bytes(buf, n_bytes) == 0 then
-- get error code
Expand Down

0 comments on commit f18898c

Please sign in to comment.