Re: [Patch] minor bugfix

2018-03-19 Thread Willy Tarreau
On Sun, Feb 25, 2018 at 09:48:21PM +0100, Thierry Fournier wrote:
> 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.

Thanks Thierry, now applied.

Willy



[Patch] minor bugfix

2018-02-25 Thread Thierry Fournier
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 
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 
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 
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(_init_functions, >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