/*
- * "$Id: ppd.c,v 1.51.2.60 2003/08/20 15:54:39 mike Exp $"
+ * "$Id: ppd.c,v 1.51.2.64 2004/06/29 03:46:29 mike Exp $"
*
* PPD file routines for the Common UNIX Printing System (CUPS).
*
* Attn: CUPS Licensing Information
* Easy Software Products
* 44141 Airport View Drive, Suite 204
- * Hollywood, Maryland 20636-3111 USA
+ * Hollywood, Maryland 20636-3142 USA
*
- * Voice: (301) 373-9603
+ * Voice: (301) 373-9600
* EMail: cups-info@cups.org
* WWW: http://www.cups.org
*
static int ppd_compare_groups(ppd_group_t *g0, ppd_group_t *g1);
static int ppd_compare_options(ppd_option_t *o0, ppd_option_t *o1);
#endif /* !__APPLE__ */
-static void ppd_decode(char *string);
+static int ppd_decode(char *string);
#ifndef __APPLE__
static void ppd_fix(char *string);
#else
cupsLangString(language, CUPS_MSG_GENERAL));
if (group == NULL)
- {
- ppd_status = PPD_ALLOC_ERROR;
-
goto error;
- }
DEBUG_printf(("Adding to group %s...\n", group->text));
option = ppd_get_option(group, keyword);
{
DEBUG_puts("Unable to get general group!");
- ppd_status = PPD_ALLOC_ERROR;
-
goto error;
}
if (name[0] == '*')
cups_strcpy(name, name + 1); /* Eliminate leading asterisk */
- for (i = strlen(name) - 1; i > 0 && isspace(name[i]); i --)
+ for (i = strlen(name) - 1; i > 0 && isspace(name[i] & 255); i --)
name[i] = '\0'; /* Eliminate trailing spaces */
DEBUG_printf(("OpenUI of %s in group %s...\n", name,
cupsLangString(language, CUPS_MSG_GENERAL));
if (group == NULL)
- {
- ppd_status = PPD_ALLOC_ERROR;
-
goto error;
- }
DEBUG_printf(("Adding to group %s...\n", group->text));
option = ppd_get_option(group, name);
group = ppd_get_group(ppd, "JCL", "JCL");
if (group == NULL)
- {
- ppd_status = PPD_ALLOC_ERROR;
-
goto error;
- }
/*
* Add an option record to the current JCLs...
group = ppd_get_group(ppd, string, sptr);
+ if (group == NULL)
+ goto error;
+
ppd_free(string);
string = NULL;
}
* 'ppd_decode()' - Decode a string value...
*/
-static void
+static int /* O - Length of decoded string */
ppd_decode(char *string) /* I - String to decode */
{
char *inptr, /* Input pointer */
outptr = string;
while (*inptr != '\0')
- if (*inptr == '<' && isxdigit(inptr[1]))
+ if (*inptr == '<' && isxdigit(inptr[1] & 255))
{
/*
* Convert hex to 8-bit values...
*/
inptr ++;
- while (isxdigit(*inptr))
+ while (isxdigit(*inptr & 255))
{
if (isalpha(*inptr))
*outptr = (tolower(*inptr) - 'a' + 10) << 4;
inptr ++;
+ if (!isxdigit(*inptr & 255))
+ break;
+
if (isalpha(*inptr))
*outptr |= tolower(*inptr) - 'a' + 10;
else
*outptr++ = *inptr++;
*outptr = '\0';
+
+ return (outptr - string);
}
{
DEBUG_printf(("Adding group %s...\n", name));
+ if (ppd_conform == PPD_CONFORM_STRICT && strlen(text) >= sizeof(group->text))
+ {
+ ppd_status = PPD_ILLEGAL_TRANSLATION;
+
+ return (NULL);
+ }
+
if (ppd->num_groups == 0)
group = malloc(sizeof(ppd_group_t));
else
(ppd->num_groups + 1) * sizeof(ppd_group_t));
if (group == NULL)
+ {
+ ppd_status = PPD_ALLOC_ERROR;
+
return (NULL);
+ }
ppd->groups = group;
group += ppd->num_groups;
colon, /* Colon seen? */
endquote, /* Waiting for an end quote */
mask, /* Mask to be returned */
- startline; /* Start line */
+ startline, /* Start line */
+ textlen; /* Length of text */
char *keyptr, /* Keyword pointer */
*optptr, /* Option pointer */
*textptr, /* Text pointer */
*/
for (lineptr = line; *lineptr; lineptr ++)
- if (!isspace(*lineptr))
+ if (!isspace(*lineptr & 255))
break;
if (*lineptr)
keyptr = keyword;
- while (*lineptr != '\0' && *lineptr != ':' && !isspace(*lineptr))
+ while (*lineptr != '\0' && *lineptr != ':' && !isspace(*lineptr & 255))
{
if (*lineptr <= ' ' || *lineptr > 126 || *lineptr == '/' ||
(keyptr - keyword) >= (PPD_MAX_NAME - 1))
/* DEBUG_printf(("keyword = \"%s\", lineptr = \"%s\"\n", keyword, lineptr));*/
- if (isspace(*lineptr))
+ if (isspace(*lineptr & 255))
{
/*
* Get an option name...
*/
- while (isspace(*lineptr))
+ while (isspace(*lineptr & 255))
lineptr ++;
optptr = option;
- while (*lineptr != '\0' && !isspace(*lineptr) && *lineptr != ':' &&
+ while (*lineptr != '\0' && !isspace(*lineptr & 255) && *lineptr != ':' &&
*lineptr != '/')
{
if (*lineptr <= ' ' || *lineptr > 126 ||
*optptr = '\0';
- if (isspace(*lineptr) && ppd_conform == PPD_CONFORM_STRICT)
+ if (isspace(*lineptr & 255) && ppd_conform == PPD_CONFORM_STRICT)
{
ppd_status = PPD_ILLEGAL_WHITESPACE;
return (0);
}
- while (isspace(*lineptr))
+ while (isspace(*lineptr & 255))
lineptr ++;
mask |= PPD_OPTION;
}
*textptr = '\0';
- ppd_decode(text);
+ textlen = ppd_decode(text);
+ if (textlen > PPD_MAX_TEXT && ppd_conform == PPD_CONFORM_STRICT)
+ {
+ ppd_status = PPD_ILLEGAL_TRANSLATION;
+ return (0);
+ }
+
mask |= PPD_TEXT;
}
/* DEBUG_printf(("text = \"%s\", lineptr = \"%s\"\n", text, lineptr));*/
}
- if (isspace(*lineptr) && ppd_conform == PPD_CONFORM_STRICT)
+ if (isspace(*lineptr & 255) && ppd_conform == PPD_CONFORM_STRICT)
{
ppd_status = PPD_ILLEGAL_WHITESPACE;
return (0);
}
- while (isspace(*lineptr))
+ while (isspace(*lineptr & 255))
lineptr ++;
if (*lineptr == ':')
*/
lineptr ++;
- while (isspace(*lineptr))
+ while (isspace(*lineptr & 255))
lineptr ++;
strptr = lineptr + strlen(lineptr) - 1;
- while (strptr >= lineptr && isspace(*strptr))
+ while (strptr >= lineptr && isspace(*strptr & 255))
*strptr-- = '\0';
if (*strptr == '\"')
/*
- * End of "$Id: ppd.c,v 1.51.2.60 2003/08/20 15:54:39 mike Exp $".
+ * End of "$Id: ppd.c,v 1.51.2.64 2004/06/29 03:46:29 mike Exp $".
*/