Hi, This is a lot of minor patches.
* The 0001 should be backported in 1.7. The backport is done in the patch v17_0001. * The 0002 should be backported in 1.7 and 1.6 * The 0003 could be backported in 1.6 and 1.7 but it is very minor and I think that is useless to backport it. BR, Thierry
>From b6a4d76cf77fc7463fe81c6f0b75c9d4dcc650dd Mon Sep 17 00:00:00 2001 From: Thierry FOURNIER <[email protected]> Date: Sun, 25 Feb 2018 21:33:38 +0100 Subject: [PATCH 1/3] BUG/MINOR: spoa-example: unexpected behavior for more than 127 args Buf is unsigned, so nbargs will be negative for more then 127 args. Note that I cant test this bug because I cant put sufficient args on the configuration line. It is just detected reading code. --- contrib/spoa_example/spoa.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/spoa_example/spoa.c b/contrib/spoa_example/spoa.c index 026f256..bf2dbe9 100644 --- a/contrib/spoa_example/spoa.c +++ b/contrib/spoa_example/spoa.c @@ -1318,7 +1318,7 @@ process_frame_cb(evutil_socket_t fd, short events, void *arg) DEBUG(frame->worker, "Process SPOE Message '%.*s'", (int)sz, str); - nbargs = *p++; /* Get the number of arguments */ + nbargs = (unsigned char)*p++; /* Get the number of arguments */ frame->offset = (p - frame->buf); /* Save index to handle errors and skip args */ if (!memcmp(str, "check-client-ip", sz)) { union spoe_data data; -- 2.9.5
>From 88ba2ea7e79538eecb2faec97e32acd0440ab44c Mon Sep 17 00:00:00 2001 From: Thierry FOURNIER <[email protected]> Date: Fri, 23 Feb 2018 18:41:18 +0100 Subject: [PATCH 2/3] BUG/MINOR: lua: return bad error messages The returned type is the type of the top of stack value and not the type of the checked argument. --- src/hlua.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hlua.c b/src/hlua.c index ebe8c92..5c56dc0 100644 --- a/src/hlua.c +++ b/src/hlua.c @@ -269,7 +269,7 @@ __LJMP static int hlua_http_get_headers(lua_State *L, struct hlua_txn *htxn, str __LJMP unsigned int hlua_checkfunction(lua_State *L, int argno) { if (!lua_isfunction(L, argno)) { - const char *msg = lua_pushfstring(L, "function expected, got %s", luaL_typename(L, -1)); + const char *msg = lua_pushfstring(L, "function expected, got %s", luaL_typename(L, argno)); WILL_LJMP(luaL_argerror(L, argno, msg)); } lua_pushvalue(L, argno); -- 2.9.5
>From a0eb161c0f800a68791a882e619ba4b168b45017 Mon Sep 17 00:00:00 2001 From: Thierry FOURNIER <[email protected]> Date: Sun, 25 Feb 2018 14:32:36 +0100 Subject: [PATCH 3/3] MINOR: lua/syntax: lua is a name and not an acronym This patch fix some first letter upercase for Lua messages. --- src/hlua.c | 68 +++++++++++++++++++++++++++++++------------------------------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/src/hlua.c b/src/hlua.c index 5c56dc0..aeb0e2d 100644 --- a/src/hlua.c +++ b/src/hlua.c @@ -5576,7 +5576,7 @@ __LJMP static int hlua_register_init(lua_State *L) init = calloc(1, sizeof(*init)); if (!init) - WILL_LJMP(luaL_error(L, "lua out of memory error.")); + WILL_LJMP(luaL_error(L, "Lua out of memory error.")); init->function_ref = ref; LIST_ADDQ(&hlua_init_functions, &init->l); @@ -5604,14 +5604,14 @@ static int hlua_register_task(lua_State *L) hlua = pool_alloc(pool_head_hlua); if (!hlua) - WILL_LJMP(luaL_error(L, "lua out of memory error.")); + WILL_LJMP(luaL_error(L, "Lua out of memory error.")); task = task_new(MAX_THREADS_MASK); task->context = hlua; task->process = hlua_process_task; if (!hlua_ctx_init(hlua, task)) - WILL_LJMP(luaL_error(L, "lua out of memory error.")); + WILL_LJMP(luaL_error(L, "Lua out of memory error.")); /* Restore the function in the stack. */ lua_rawgeti(hlua->T, LUA_REGISTRYINDEX, ref); @@ -5897,15 +5897,15 @@ __LJMP static int hlua_register_converters(lua_State *L) /* Allocate and fill the sample fetch keyword struct. */ sck = calloc(1, sizeof(*sck) + sizeof(struct sample_conv) * 2); if (!sck) - WILL_LJMP(luaL_error(L, "lua out of memory error.")); + WILL_LJMP(luaL_error(L, "Lua out of memory error.")); fcn = calloc(1, sizeof(*fcn)); if (!fcn) - WILL_LJMP(luaL_error(L, "lua out of memory error.")); + WILL_LJMP(luaL_error(L, "Lua out of memory error.")); /* Fill fcn. */ fcn->name = strdup(name); if (!fcn->name) - WILL_LJMP(luaL_error(L, "lua out of memory error.")); + WILL_LJMP(luaL_error(L, "Lua out of memory error.")); fcn->function_ref = ref; /* List head */ @@ -5915,7 +5915,7 @@ __LJMP static int hlua_register_converters(lua_State *L) len = strlen("lua.") + strlen(name) + 1; sck->kw[0].kw = calloc(1, len); if (!sck->kw[0].kw) - WILL_LJMP(luaL_error(L, "lua out of memory error.")); + WILL_LJMP(luaL_error(L, "Lua out of memory error.")); snprintf((char *)sck->kw[0].kw, len, "lua.%s", name); sck->kw[0].process = hlua_sample_conv_wrapper; @@ -5954,15 +5954,15 @@ __LJMP static int hlua_register_fetches(lua_State *L) /* Allocate and fill the sample fetch keyword struct. */ sfk = calloc(1, sizeof(*sfk) + sizeof(struct sample_fetch) * 2); if (!sfk) - WILL_LJMP(luaL_error(L, "lua out of memory error.")); + WILL_LJMP(luaL_error(L, "Lua out of memory error.")); fcn = calloc(1, sizeof(*fcn)); if (!fcn) - WILL_LJMP(luaL_error(L, "lua out of memory error.")); + WILL_LJMP(luaL_error(L, "Lua out of memory error.")); /* Fill fcn. */ fcn->name = strdup(name); if (!fcn->name) - WILL_LJMP(luaL_error(L, "lua out of memory error.")); + WILL_LJMP(luaL_error(L, "Lua out of memory error.")); fcn->function_ref = ref; /* List head */ @@ -5972,7 +5972,7 @@ __LJMP static int hlua_register_fetches(lua_State *L) len = strlen("lua.") + strlen(name) + 1; sfk->kw[0].kw = calloc(1, len); if (!sfk->kw[0].kw) - return luaL_error(L, "lua out of memory error."); + return luaL_error(L, "Lua out of memory error."); snprintf((char *)sfk->kw[0].kw, len, "lua.%s", name); sfk->kw[0].process = hlua_sample_fetch_wrapper; @@ -6758,15 +6758,15 @@ __LJMP static int hlua_register_action(lua_State *L) /* Allocate and fill the sample fetch keyword struct. */ akl = calloc(1, sizeof(*akl) + sizeof(struct action_kw) * 2); if (!akl) - WILL_LJMP(luaL_error(L, "lua out of memory error.")); + WILL_LJMP(luaL_error(L, "Lua out of memory error.")); fcn = calloc(1, sizeof(*fcn)); if (!fcn) - WILL_LJMP(luaL_error(L, "lua out of memory error.")); + WILL_LJMP(luaL_error(L, "Lua out of memory error.")); /* Fill fcn. */ fcn->name = strdup(name); if (!fcn->name) - WILL_LJMP(luaL_error(L, "lua out of memory error.")); + WILL_LJMP(luaL_error(L, "Lua out of memory error.")); fcn->function_ref = ref; /* Set the expected number od arguments. */ @@ -6779,7 +6779,7 @@ __LJMP static int hlua_register_action(lua_State *L) len = strlen("lua.") + strlen(name) + 1; akl->kw[0].kw = calloc(1, len); if (!akl->kw[0].kw) - WILL_LJMP(luaL_error(L, "lua out of memory error.")); + WILL_LJMP(luaL_error(L, "Lua out of memory error.")); snprintf((char *)akl->kw[0].kw, len, "lua.%s", name); @@ -6797,7 +6797,7 @@ __LJMP static int hlua_register_action(lua_State *L) else if (strcmp(lua_tostring(L, -1), "http-res") == 0) http_res_keywords_register(akl); else - WILL_LJMP(luaL_error(L, "lua action environment '%s' is unknown. " + WILL_LJMP(luaL_error(L, "Lua action environment '%s' is unknown. " "'tcp-req', 'tcp-res', 'http-req' or 'http-res' " "are expected.", lua_tostring(L, -1))); @@ -6863,16 +6863,16 @@ __LJMP static int hlua_register_service(lua_State *L) /* Allocate and fill the sample fetch keyword struct. */ akl = calloc(1, sizeof(*akl) + sizeof(struct action_kw) * 2); if (!akl) - WILL_LJMP(luaL_error(L, "lua out of memory error.")); + WILL_LJMP(luaL_error(L, "Lua out of memory error.")); fcn = calloc(1, sizeof(*fcn)); if (!fcn) - WILL_LJMP(luaL_error(L, "lua out of memory error.")); + WILL_LJMP(luaL_error(L, "Lua out of memory error.")); /* Fill fcn. */ len = strlen("<lua.>") + strlen(name) + 1; fcn->name = calloc(1, len); if (!fcn->name) - WILL_LJMP(luaL_error(L, "lua out of memory error.")); + WILL_LJMP(luaL_error(L, "Lua out of memory error.")); snprintf((char *)fcn->name, len, "<lua.%s>", name); fcn->function_ref = ref; @@ -6883,7 +6883,7 @@ __LJMP static int hlua_register_service(lua_State *L) len = strlen("lua.") + strlen(name) + 1; akl->kw[0].kw = calloc(1, len); if (!akl->kw[0].kw) - WILL_LJMP(luaL_error(L, "lua out of memory error.")); + WILL_LJMP(luaL_error(L, "Lua out of memory error.")); snprintf((char *)akl->kw[0].kw, len, "lua.%s", name); @@ -6893,7 +6893,7 @@ __LJMP static int hlua_register_service(lua_State *L) else if (strcmp(env, "http") == 0) akl->kw[0].parse = action_register_service_http; else - WILL_LJMP(luaL_error(L, "lua service environment '%s' is unknown. " + WILL_LJMP(luaL_error(L, "Lua service environment '%s' is unknown. " "'tcp' or 'http' are expected.", env)); akl->kw[0].match_pfx = 0; @@ -7093,10 +7093,10 @@ __LJMP static int hlua_register_cli(lua_State *L) /* Allocate and fill the sample fetch keyword struct. */ cli_kws = calloc(1, sizeof(*cli_kws) + sizeof(struct cli_kw) * 2); if (!cli_kws) - WILL_LJMP(luaL_error(L, "lua out of memory error.")); + WILL_LJMP(luaL_error(L, "Lua out of memory error.")); fcn = calloc(1, sizeof(*fcn)); if (!fcn) - WILL_LJMP(luaL_error(L, "lua out of memory error.")); + WILL_LJMP(luaL_error(L, "Lua out of memory error.")); /* Fill path. */ index = 0; @@ -7108,7 +7108,7 @@ __LJMP static int hlua_register_cli(lua_State *L) WILL_LJMP(luaL_argerror(L, 1, "1st argument must be a table filled with strings")); cli_kws->kw[0].str_kw[index] = strdup(lua_tostring(L, -1)); if (!cli_kws->kw[0].str_kw[index]) - WILL_LJMP(luaL_error(L, "lua out of memory error.")); + WILL_LJMP(luaL_error(L, "Lua out of memory error.")); index++; lua_pop(L, 1); } @@ -7116,7 +7116,7 @@ __LJMP static int hlua_register_cli(lua_State *L) /* Copy help message. */ cli_kws->kw[0].usage = strdup(message); if (!cli_kws->kw[0].usage) - WILL_LJMP(luaL_error(L, "lua out of memory error.")); + WILL_LJMP(luaL_error(L, "Lua out of memory error.")); /* Fill fcn io handler. */ len = strlen("<lua.cli>") + 1; @@ -7124,7 +7124,7 @@ __LJMP static int hlua_register_cli(lua_State *L) len += strlen(cli_kws->kw[0].str_kw[i]) + 1; fcn->name = calloc(1, len); if (!fcn->name) - WILL_LJMP(luaL_error(L, "lua out of memory error.")); + WILL_LJMP(luaL_error(L, "Lua out of memory error.")); strncat((char *)fcn->name, "<lua.cli", len); for (i = 0; i < index; i++) { strncat((char *)fcn->name, ".", len); @@ -7239,7 +7239,7 @@ static int hlua_load(char **args, int section_type, struct proxy *curpx, /* Just load and compile the file. */ error = luaL_loadfile(gL.T, args[1]); if (error) { - memprintf(err, "error in lua file '%s': %s", args[1], lua_tostring(gL.T, -1)); + memprintf(err, "error in Lua file '%s': %s", args[1], lua_tostring(gL.T, -1)); lua_pop(gL.T, 1); return -1; } @@ -7250,22 +7250,22 @@ static int hlua_load(char **args, int section_type, struct proxy *curpx, case LUA_OK: break; case LUA_ERRRUN: - memprintf(err, "lua runtime error: %s\n", lua_tostring(gL.T, -1)); + memprintf(err, "Lua runtime error: %s\n", lua_tostring(gL.T, -1)); lua_pop(gL.T, 1); return -1; case LUA_ERRMEM: - memprintf(err, "lua out of memory error\n"); + memprintf(err, "Lua out of memory error.n"); return -1; case LUA_ERRERR: - memprintf(err, "lua message handler error: %s\n", lua_tostring(gL.T, -1)); + memprintf(err, "Lua message handler error: %s\n", lua_tostring(gL.T, -1)); lua_pop(gL.T, 1); return -1; case LUA_ERRGCMM: - memprintf(err, "lua garbage collector error: %s\n", lua_tostring(gL.T, -1)); + memprintf(err, "Lua garbage collector error: %s\n", lua_tostring(gL.T, -1)); lua_pop(gL.T, 1); return -1; default: - memprintf(err, "lua unknonwn error: %s\n", lua_tostring(gL.T, -1)); + memprintf(err, "Lua unknonwn error: %s\n", lua_tostring(gL.T, -1)); lua_pop(gL.T, 1); return -1; } @@ -7315,7 +7315,7 @@ int hlua_post_init() lua_pop(gL.T, -1); return 1; case HLUA_E_AGAIN: - ha_alert("lua init: yield not allowed.\n"); + ha_alert("Lua init: yield not allowed.\n"); return 0; case HLUA_E_ERRMSG: msg = lua_tostring(gL.T, -1); @@ -7323,7 +7323,7 @@ int hlua_post_init() return 0; case HLUA_E_ERR: default: - ha_alert("lua init: unknown runtime error.\n"); + ha_alert("Lua init: unknown runtime error.\n"); return 0; } } -- 2.9.5
>From 02a30d6b0bf373da04b1b8d882b17ff68a764a54 Mon Sep 17 00:00:00 2001 From: Thierry FOURNIER <[email protected]> Date: Fri, 23 Feb 2018 12:09:10 +0100 Subject: [PATCH] BUG/MINOR: spoa-example: unexpected behavior for more than 127 args Buf is unsigned, so nbargs will be negative for more then 127 args. Note that I cant test this bug because i cant put sufficient args on the configuration line. It is just detected reading code. --- contrib/spoa_example/spoa.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/spoa_example/spoa.c b/contrib/spoa_example/spoa.c index ce59c04..3bd8fa3 100644 --- a/contrib/spoa_example/spoa.c +++ b/contrib/spoa_example/spoa.c @@ -770,7 +770,7 @@ handle_hanotify(struct worker *w) } DEBUG(" Message '%.*s' received", (int)sz, str); - nbargs = w->buf[idx++]; + nbargs = (unsigned char)w->buf[idx++]; if (!memcmp(str, "check-client-ip", sz)) { struct spoe_data data; -- 2.9.5

