Package: qcontrol
Version: 0.4.2+svn-r40-3
Severity: normal
Tags: patch

Hi,

when passing a lua nil (or anything not a string or a number) value as second
(or higher) arg to piccmd() qcontrol dies.
This is because piccmd()s lcd-line0 / lcd-line1 commands do a strlen() on a NULL
value. get_args() calls lua_tostring(), but this returns NULL for anything not
a number or a string...

        Hanno

-- System Information:
Debian Release: 7.0
  APT prefers testing-updates
  APT policy: (500, 'testing-updates'), (500, 'testing')
Architecture: armel (armv5tel)

Kernel: Linux 3.2.0-4-kirkwood
Locale: LANG=C.UTF-8, LC_CTYPE=C.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages qcontrol depends on:
ii  libc6        2.13-37
ii  liblua5.1-0  5.1.5-4
ii  udev         175-7

qcontrol recommends no packages.

qcontrol suggests no packages.

-- Configuration Files:
/etc/qcontrol/ts41x.lua changed [not included]

-- no debconf information
--- qcontrol.orig/qcontrol.c	2013-01-20 09:38:27.903838894 +0100
+++ qcontrol/qcontrol.c	2013-01-20 09:40:50.885882680 +0100
@@ -163,7 +163,15 @@
 	*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);
+		switch (lua_type(lua, i)) {
+			case LUA_TSTRING:
+			case LUA_TNUMBER:
+				*(*argv + i - 1) = (const char*) lua_tostring(lua, i);
+				break;
+			default:
+				*(*argv + i - 1) = (const char*) "";
+				break;
+		}
 	}
 	return 0;
 }

Reply via email to