mirror of
https://gitlab.alpinelinux.org/alpine/aports.git
synced 2026-04-16 11:12:08 +02:00
49 lines
1.6 KiB
Diff
49 lines
1.6 KiB
Diff
From 49ea990493039729e5a856f8bb3c758a0aa98a78 Mon Sep 17 00:00:00 2001
|
|
From: Kaarle Ritvanen <kaarle.ritvanen@datakunkku.fi>
|
|
Date: Sun, 2 Sep 2018 14:40:07 +0300
|
|
Subject: [PATCH 06/10] optencoding: allow negative indices
|
|
|
|
---
|
|
src/openssl.c | 14 +++++++++++---
|
|
1 file changed, 11 insertions(+), 3 deletions(-)
|
|
|
|
diff --git a/src/openssl.c b/src/openssl.c
|
|
index 5904bf1..cb38f2f 100644
|
|
--- a/src/openssl.c
|
|
+++ b/src/openssl.c
|
|
@@ -846,8 +846,12 @@ static int optencoding(lua_State *L, int index, const char *def, int allow) {
|
|
break;
|
|
}
|
|
|
|
- if (!(type & allow))
|
|
- luaL_argerror(L, index, lua_pushfstring(L, "invalid option %s", luaL_checkstring(L, index)));
|
|
+ if (!(type & allow)) {
|
|
+ const char *arg = luaL_checkstring(L, index);
|
|
+ if (index > 0)
|
|
+ luaL_argerror(L, index, lua_pushfstring(L, "invalid format: %s", arg));
|
|
+ luaL_error(L, "invalid format: %s", arg);
|
|
+ }
|
|
|
|
return type;
|
|
} /* optencoding() */
|
|
@@ -1186,11 +1190,15 @@ static int auxL_testoption(lua_State *L, int index, const char *def, const char
|
|
|
|
static int auxL_checkoption(lua_State *L, int index, const char *def, const char *const *optlist, _Bool nocase) {
|
|
int i;
|
|
+ const char *arg;
|
|
|
|
if ((i = auxL_testoption(L, index, def, optlist, nocase)) >= 0)
|
|
return i;
|
|
|
|
- return luaL_argerror(L, index, lua_pushfstring(L, "invalid option '%s'", luaL_optstring(L, index, def)));
|
|
+ arg = luaL_optstring(L, index, def);
|
|
+ if (index > 0)
|
|
+ return luaL_argerror(L, index, lua_pushfstring(L, "invalid option '%s'", arg));
|
|
+ return luaL_error(L, "invalid option '%s'", arg);
|
|
} /* auxL_checkoption() */
|
|
|
|
/*
|
|
--
|
|
2.24.1
|
|
|