1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-12-24 11:55:43 +00:00

hopefully fix spaced_print

* when printing only width bytes to buf, with
  width being set to pad_percents which itself
  is set by the user to zero, nothing is printed
* in the unlikely (but possible) case of width > size,
  this could lead to a segfault


git-svn-id: https://conky.svn.sourceforge.net/svnroot/conky/trunk/conky1@1029 7f574dfc-610e-0410-a909-a81674777703
This commit is contained in:
Phil 2008-03-22 18:18:25 +00:00
parent c1cb65ff6d
commit 9b222e23e9

View File

@ -988,10 +988,10 @@ static int spaced_print(char *buf, int size, char *format, int width,
len = snprintf(buf, size, "%s", tempbuf);
break;
case LEFT_SPACER:
len = snprintf(buf, width, "%*s", width - 1, tempbuf);
len = snprintf(buf, size, "%*s", width - 1, tempbuf);
break;
case RIGHT_SPACER:
len = snprintf(buf, width, "%-*s", width - 1, tempbuf);
len = snprintf(buf, size, "%-*s", width - 1, tempbuf);
break;
default:
CRIT_ERR("%s encountered invalid use_spacer value (%d)", func_name,