mirror of
https://github.com/Llewellynvdm/conky.git
synced 2024-12-23 19:39:06 +00:00
Fix buffer overflow in parsing LC_ALL, LC_CTYPE and LANG environment
variables by using dynamic arrays for storing it. This should fix a core dumps for users with locale name longer than 10 chars. git-svn-id: https://conky.svn.sourceforge.net/svnroot/conky/trunk/conky1@707 7f574dfc-610e-0410-a909-a81674777703
This commit is contained in:
parent
fa2477a8d8
commit
18a86d7075
12
src/conky.c
12
src/conky.c
@ -6906,19 +6906,23 @@ int main(int argc, char **argv)
|
||||
|
||||
/* handle command line parameters that don't change configs */
|
||||
#ifdef X11
|
||||
char *s;
|
||||
char temp[10];
|
||||
char *s, *temp;
|
||||
unsigned int x;
|
||||
|
||||
if (((s = getenv("LC_ALL")) && *s) || ((s = getenv("LC_CTYPE")) &&
|
||||
*s) || ((s = getenv("LANG")) && *s)) {
|
||||
strcpy(temp, s);
|
||||
for(x = 0; x < strlen(s) ; x++) {
|
||||
temp = (char *)malloc((strlen(s) + 1) * sizeof(char));
|
||||
if (temp == NULL) {
|
||||
ERR("malloc failed");
|
||||
}
|
||||
for (x = 0; x < strlen(s); x++) {
|
||||
temp[x] = tolower(s[x]);
|
||||
}
|
||||
if (strstr(temp, "utf-8") || strstr(temp, "utf8")) {
|
||||
utf8_mode = 1;
|
||||
}
|
||||
|
||||
free(temp);
|
||||
}
|
||||
if (!setlocale(LC_CTYPE, "")) {
|
||||
ERR("Can't set the specified locale!\nCheck LANG, LC_CTYPE, LC_ALL.");
|
||||
|
Loading…
Reference in New Issue
Block a user