poldek: poldek/misc.c - fixes crash on invalid locale (pl.UTF_8 instead of ...
megabajt
megabajt at pld-linux.org
Sun Nov 23 16:01:52 CET 2008
Author: megabajt Date: Sun Nov 23 15:01:52 2008 GMT
Module: poldek Tag: HEAD
---- Log message:
- fixes crash on invalid locale (pl.UTF_8 instead of pl.UTF-8)
---- Files affected:
poldek/poldek:
misc.c (1.67 -> 1.68)
---- Diffs:
================================================================
Index: poldek/poldek/misc.c
diff -u poldek/poldek/misc.c:1.67 poldek/poldek/misc.c:1.68
--- poldek/poldek/misc.c:1.67 Thu Sep 18 23:38:53 2008
+++ poldek/poldek/misc.c Sun Nov 23 16:01:47 2008
@@ -626,7 +626,7 @@
*/
static char *cut_country_code (const char *lang)
{
- char *p, *q, *newlang;
+ char *c, *p, *q, *newlang;
if ((q = strchr(lang, '_')) == NULL)
return NULL;
@@ -636,10 +636,12 @@
p = n_strncpy(newlang, lang, q - lang + 1);
- if ((q = strchr(lang, '.')))
- n_strncpy(p, q, strlen(q) + 1);
- else if ((q = strchr(lang, '@')))
- n_strncpy(p, q, strlen(q) + 1);
+ if ((c = strchr(q, '.')))
+ n_strncpy(p, c, strlen(c) + 1);
+ else if ((c = strchr(q, '@')))
+ n_strncpy(p, c, strlen(c) + 1);
+
+ n_assert(strlen(lang) > strlen(newlang));
return newlang;
}
================================================================
---- CVS-web:
http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/poldek/poldek/misc.c?r1=1.67&r2=1.68&f=u
More information about the pld-cvs-commit
mailing list