mirror of
https://github.com/Llewellynvdm/conky.git
synced 2025-01-14 11:33:14 +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:
parent
4be537a020
commit
f44003e07c
@ -4218,7 +4218,7 @@ static struct text_object *construct_text_object(const char *s,
|
|||||||
int n;
|
int n;
|
||||||
|
|
||||||
obj->data.scroll.step = 1;
|
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.text = strndup(arg + n, text_buffer_size);
|
||||||
obj->data.scroll.start = 0;
|
obj->data.scroll.start = 0;
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user