Control: tag -1 +pending

On Mon, 2013-01-28 at 13:13 +0000, Ian Campbell wrote:
> This issue isn't exposed on Wheezy (no LCD support) but I'll look into
> fixing this in Sid (bit busy right now, but I'll get to it). 

I got to it in the end!

I'm just about to apply the following to the git tree. It differs from
your patch in that it relies on lua_tostring() to determine which types
can be handled, rather than trying to duplicate that knowledge in the
caller, and it errors out (gracefully, I hope!) instead of trying to
substitute "".

Thanks for your report and the initial patch.

Cheers,
Ian.

Sanity check arguments to functions called from LUA.

lua_tostring() only works for LUA_TSTRING and LUA_TNUMBER and returns NULL
otherwise.
--- a/qcontrol.c
+++ b/qcontrol.c
@@ -163,7 +163,10 @@
        *argc = lua_gettop(lua);
        *argv = (const char **) calloc(*argc, sizeof(char*));
        for (i = 1; i <= *argc; ++i) {
-               *(*argv + i - 1) = (const char*) lua_tostring(lua, i);
+               const char *arg = (const char*) lua_tostring(lua, i);
+               if (!arg)
+                       return -1;
+               *(*argv + i - 1) = arg;
        }
        return 0;
 }
@@ -174,8 +177,10 @@
        const char **argv;
 
        err = get_args(&argc, &argv);
-       if (err < 0)
+       if (err < 0) {
                print_log(LOG_ERR, "register() - Error getting arguments");
+               return err;
+       }
 
        for (i = 0; modules[i]; ++i) {
                if (strcmp(argv[0], modules[i]->name) != 0)

-- 
Ian Campbell


Old MacDonald had an agricultural real estate tax abatement.

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to