1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-09-29 21:49:07 +00:00

fix a potential segfault

* happened when passing wrong arguments to ${scroll}, particularly with only
  one instead of the mandatory two unsigned ints
* as it's not clear whether %n will change the value returned by sscanf or not,
  use a solution that works in both situations (%n incrementing the return
  value or not)


git-svn-id: https://conky.svn.sourceforge.net/svnroot/conky/trunk/conky1@1268 7f574dfc-610e-0410-a909-a81674777703
This commit is contained in:
Phil 2008-11-04 21:42:48 +00:00
parent 4be537a020
commit f44003e07c

View File

@ -4218,7 +4218,7 @@ static struct text_object *construct_text_object(const char *s,
int n;
obj->data.scroll.step = 1;
if (arg && sscanf(arg, "%u %u %n", &obj->data.scroll.show, &obj->data.scroll.step, &n) > 0) {
if (arg && sscanf(arg, "%u %u %n", &obj->data.scroll.show, &obj->data.scroll.step, &n) >= 2) {
obj->data.scroll.text = strndup(arg + n, text_buffer_size);
obj->data.scroll.start = 0;
} else {