Bug#440256: Bug is fixed in current CUPS SVN
Hi,
just to let you know: this bug is caused by incorrect use of sizeof
on a char* (instead of char[]) in function ppd_ll_CC in cups/localize.
I have attached the output of
svn diff -x -ub
http://svn.easysw.com/public/cups/{tags/release-1.3.0,branches/branch-1.3}/cups/localize.c
Cheers, Roderich
Index: localize.c
===================================================================
--- localize.c (.../tags/release-1.3.0/cups/localize.c) (revision 6930)
+++ localize.c (.../branches/branch-1.3/cups/localize.c) (revision 6930)
@@ -44,7 +44,8 @@
* Local functions...
*/
-static void ppd_ll_CC(char *ll_CC, char *ll);
+static void ppd_ll_CC(char *ll_CC, int ll_CC_size,
+ char *ll, int ll_size);
static ppd_attr_t *ppd_localized_attr(ppd_file_t *ppd,
const char *keyword,
const char *spec, const char *ll_CC,
@@ -90,7 +91,7 @@
* Get the default language...
*/
- ppd_ll_CC(ll_CC, ll);
+ ppd_ll_CC(ll_CC, sizeof(ll_CC), ll, sizeof(ll));
/*
* Now lookup all of the groups, options, choices, etc.
@@ -240,7 +241,7 @@
* Get the default language...
*/
- ppd_ll_CC(ll_CC, ll);
+ ppd_ll_CC(ll_CC, sizeof(ll_CC), ll, sizeof(ll));
/*
* Find the localized attribute...
@@ -391,8 +392,9 @@
static void
ppd_ll_CC(char *ll_CC, /* O - Country-specific locale name */
- char *ll) /* O - Generic locale name */
-
+ int ll_CC_size, /* I - Size of country-specific name */
+ char *ll, /* O - Generic locale name */
+ int ll_size) /* I - Size of generic name */
{
cups_lang_t *lang; /* Current language */
@@ -403,8 +405,8 @@
if ((lang = cupsLangDefault()) == NULL)
{
- strcpy(ll_CC, "en_US");
- strcpy(ll, "en");
+ strlcpy(ll_CC, "en_US", ll_CC_size);
+ strlcpy(ll, "en", ll_size);
return;
}
@@ -412,9 +414,11 @@
* Copy the locale name...
*/
- strlcpy(ll_CC, lang->language, sizeof(ll_CC));
- strlcpy(ll, lang->language, sizeof(ll));
+ strlcpy(ll_CC, lang->language, ll_CC_size);
+ strlcpy(ll, lang->language, ll_size);
+ DEBUG_printf(("ll_CC=\"%s\", ll=\"%s\"\n", ll_CC, ll));
+
if (strlen(ll_CC) == 2)
{
/*
@@ -423,16 +427,16 @@
*/
if (!strcmp(ll_CC, "cs"))
- strcpy(ll_CC, "cs_CZ");
+ strlcpy(ll_CC, "cs_CZ", ll_CC_size);
else if (!strcmp(ll_CC, "en"))
- strcpy(ll_CC, "en_US");
+ strlcpy(ll_CC, "en_US", ll_CC_size);
else if (!strcmp(ll_CC, "ja"))
- strcpy(ll_CC, "ja_JP");
+ strlcpy(ll_CC, "ja_JP", ll_CC_size);
else if (!strcmp(ll_CC, "sv"))
- strcpy(ll_CC, "sv_SE");
- else if (!strcmp(ll_CC, "zh"))
- strcpy(ll_CC, "zh_CN"); /* Simplified Chinese */
- else
+ strlcpy(ll_CC, "sv_SE", ll_CC_size);
+ else if (!strcmp(ll_CC, "zh")) /* Simplified Chinese */
+ strlcpy(ll_CC, "zh_CN", ll_CC_size);
+ else if (ll_CC_size >= 6)
{
ll_CC[2] = '_';
ll_CC[3] = toupper(ll_CC[0] & 255);
@@ -475,8 +479,10 @@
snprintf(lkeyword, sizeof(lkeyword), "%s.%s", ll, keyword);
attr = ppdFindAttr(ppd, lkeyword, spec);
- if (!attr && !strcmp(ll, "ja"))
+ if (!attr)
{
+ if (!strcmp(ll, "ja"))
+ {
/*
* Due to a bug in the CUPS DDK 1.1.0 ppdmerge program, Japanese
* PPD files were incorrectly assigned "jp" as the locale name
@@ -487,7 +493,19 @@
snprintf(lkeyword, sizeof(lkeyword), "jp.%s", keyword);
attr = ppdFindAttr(ppd, lkeyword, spec);
}
+ else if (!strcmp(ll, "no"))
+ {
+ /*
+ * Norway has two languages, "Bokmal" (the primary one)
+ * and "Nynorsk" (new Norwegian); we map "no" to "nb" here as
+ * recommended by the locale folks...
+ */
+
+ snprintf(lkeyword, sizeof(lkeyword), "nb.%s", keyword);
+ attr = ppdFindAttr(ppd, lkeyword, spec);
}
+ }
+ }
#ifdef DEBUG
if (attr)
Reply to: