From 008351573a518ab92aea5431363e9d45414ec26a Mon Sep 17 00:00:00 2001 From: Cloud Wu Date: Fri, 18 Sep 2015 14:13:16 +0800 Subject: [PATCH] raise error when DH param is 0 --- lualib-src/lua-crypt.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lualib-src/lua-crypt.c b/lualib-src/lua-crypt.c index 2cb11f40..405679a9 100644 --- a/lualib-src/lua-crypt.c +++ b/lualib-src/lua-crypt.c @@ -725,10 +725,8 @@ ldhsecret(lua_State *L) { read64(L, x, y); uint64_t xx = (uint64_t)x[0] | (uint64_t)x[1]<<32; uint64_t yy = (uint64_t)y[0] | (uint64_t)y[1]<<32; - if (xx == 0) - xx = 1; - if (yy == 0) - yy = 1; + if (xx == 0 || yy == 0) + return luaL_error(L, "Can't be 0"); uint64_t r = powmodp(xx, yy); push64(L, r); @@ -751,7 +749,7 @@ ldhexchange(lua_State *L) { uint64_t x64 = (uint64_t)xx[0] | (uint64_t)xx[1]<<32; if (x64 == 0) - x64 = 1; + return luaL_error(L, "Can't be 0"); uint64_t r = powmodp(5, x64); push64(L, r);