]> source.dussan.org Git - rspamd.git/commitdiff
[Fix] Fix couple of issues with arguments in lua_redis
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 16 Mar 2016 16:42:23 +0000 (16:42 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 16 Mar 2016 16:42:23 +0000 (16:42 +0000)
src/lua/lua_redis.c

index 4f09c3a9626720ac80792e65d0800fd329d06d93..abd25a93fe532210cf06afd9a242ef24415e8562 100644 (file)
@@ -351,7 +351,9 @@ lua_redis_parse_args (lua_State *L, gint idx, const gchar *cmd,
                top = 1;
 
                while (lua_next (L, -2) != 0) {
-                       args[top++] = g_strdup (lua_tostring (L, -1));
+                       if (lua_isstring (L, -1)) {
+                               args[top++] = g_strdup (lua_tostring (L, -1));
+                       }
                        lua_pop (L, 1);
                }
 
@@ -874,10 +876,18 @@ lua_redis_connect_sync (lua_State *L)
                }
 
                if (ctx->d.sync == NULL || ctx->d.sync->err) {
-                       REF_RELEASE (ctx);
                        lua_pushboolean (L, FALSE);
 
-                       return 1;
+                       if (ctx->d.sync) {
+                               lua_pushstring (L, ctx->d.sync->errstr);
+                       }
+                       else {
+                               lua_pushstring (L, "unknown error");
+                       }
+
+                       REF_RELEASE (ctx);
+
+                       return 2;
                }
 
                pctx = lua_newuserdata (L, sizeof (ctx));
@@ -889,8 +899,10 @@ lua_redis_connect_sync (lua_State *L)
                if (ip) {
                        rspamd_inet_address_destroy (ip);
                }
-               msg_err ("bad arguments for redis request");
+
                lua_pushboolean (L, FALSE);
+               lua_pushstring (L, "bad arguments for redis request");
+               return 2;
        }
 
        return 1;