diff options
-rw-r--r-- | src/openssl.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/openssl.c b/src/openssl.c index 4ca8da7..dba7c75 100644 --- a/src/openssl.c +++ b/src/openssl.c | |||
@@ -1686,7 +1686,7 @@ static BIGNUM *(checkbig)(lua_State *L, int index, _Bool *lvalue) { | |||
1686 | BIGNUM **bn; | 1686 | BIGNUM **bn; |
1687 | const char *str; | 1687 | const char *str; |
1688 | size_t len, i; | 1688 | size_t len, i; |
1689 | _Bool neg, hex = 0; | 1689 | _Bool neg, hex; |
1690 | 1690 | ||
1691 | index = lua_absindex(L, index); | 1691 | index = lua_absindex(L, index); |
1692 | 1692 | ||
@@ -1696,17 +1696,17 @@ static BIGNUM *(checkbig)(lua_State *L, int index, _Bool *lvalue) { | |||
1696 | 1696 | ||
1697 | str = lua_tolstring(L, index, &len); | 1697 | str = lua_tolstring(L, index, &len); |
1698 | 1698 | ||
1699 | luaL_argcheck(L, len > 0 && *str, index, "invalid big number string"); | ||
1700 | |||
1701 | neg = (str[0] == '-'); | 1699 | neg = (str[0] == '-'); |
1700 | hex = (str[neg] == '0' && (str[neg+1] == 'x' || str[neg+1] == 'X')); | ||
1702 | 1701 | ||
1703 | if (str[neg] == '0' && (str[neg+1] == 'x' || str[neg+1] == 'X')) { | 1702 | if (hex) { |
1704 | hex = 1; | 1703 | luaL_argcheck(L, len > 2+(size_t)neg, index, "invalid hex string"); |
1705 | for (i = 2+neg; i < len; i++) { | 1704 | for (i = 2+neg; i < len; i++) { |
1706 | if (!isxdigit(str[i])) | 1705 | if (!isxdigit(str[i])) |
1707 | luaL_argerror(L, 1, "invalid hex string"); | 1706 | luaL_argerror(L, 1, "invalid hex string"); |
1708 | } | 1707 | } |
1709 | } else { | 1708 | } else { |
1709 | luaL_argcheck(L, len > neg, index, "invalid decimal string"); | ||
1710 | for (i = neg; i < len; i++) { | 1710 | for (i = neg; i < len; i++) { |
1711 | if (!isdigit(str[i])) | 1711 | if (!isdigit(str[i])) |
1712 | luaL_argerror(L, 1, "invalid decimal string"); | 1712 | luaL_argerror(L, 1, "invalid decimal string"); |