Hello,
let's consider the following wibox:
testbox[1] = awful.wibox({ screen = 1, position = "top", width = 500, height =
18 })
-- and to make the scenario more plausible
awful.wibox.align(testbox[1], "center", 1)
When both height and width arguments are provided to the function
new() there is a check to see if one of them was a screen
percentage, and is expected to be a string. If the user provided
absolute pixels, and argument is of type number awesome will
crash.
Attached patch (made on the 3.4 branch) uses tostring to sanitize the
arguments during this check.
--
Adrian C. (anrxc) | anrxc..sysphere.org | PGP ID: D20A0618
PGP FP: 02A5 628A D8EE 2A93 996E 929F D5CB 31B7 D20A 0618
From afc29f5d4f1052f0d6a69afb5628dd98477634c4 Mon Sep 17 00:00:00 2001
From: Adrian C. (anrxc) <[email protected]>
Date: Mon, 4 Jan 2010 23:37:16 +0100
Subject: [PATCH] awful.wibox: sanitize height/width args to function new()
When both height and width arguments are provided to the function
new() there is a check to see if one of them was a screen percentage,
and is expected to be a string. If the user provided absolute pixels,
and argument is of type number awesome will crash. Now tostring is
used to sanitize the arguments during this check.
Signed-off-by: Adrian C. (anrxc) <[email protected]>
---
lib/awful/wibox.lua.in | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/lib/awful/wibox.lua.in b/lib/awful/wibox.lua.in
index e458d04..7d80a6b 100644
--- a/lib/awful/wibox.lua.in
+++ b/lib/awful/wibox.lua.in
@@ -13,6 +13,7 @@ local capi =
client = client
}
local setmetatable = setmetatable
+local tostring = tostring
local ipairs = ipairs
local table = table
local type = type
@@ -226,7 +227,7 @@ function new(arg)
if arg.height then
has_to_stretch = false
if arg.screen then
- local hp = arg.height:match("(%d+)%%")
+ local hp = tostring(arg.height):match("(%d+)%%")
if hp then
arg.height = capi.screen[arg.screen].geometry.height * hp
/ 100
end
@@ -237,7 +238,7 @@ function new(arg)
if arg.width then
has_to_stretch = false
if arg.screen then
- local wp = arg.width:match("(%d+)%%")
+ local wp = tostring(arg.width):match("(%d+)%%")
if wp then
arg.width = capi.screen[arg.screen].geometry.width * wp /
100
end
--
1.6.6