/*
* Internet Printing Protocol functions for CUPS.
*
- * Copyright 2007-2017 by Apple Inc.
- * Copyright 1997-2007 by Easy Software Products, all rights reserved.
+ * Copyright © 2007-2021 by Apple Inc.
+ * Copyright © 1997-2007 by Easy Software Products, all rights reserved.
*
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law. Distribution and use rights are outlined in the file "LICENSE.txt"
- * which should have been included with this file. If this file is
- * missing or damaged, see the license at "http://www.cups.org/".
- *
- * This file is subject to the Apple OS-Developed Software exception.
+ * Licensed under Apache License v2.0. See the file "LICENSE" for more
+ * information.
*/
/*
*/
#include "cups-private.h"
+#include "debug-internal.h"
#include <regex.h>
-#ifdef WIN32
+#ifdef _WIN32
# include <io.h>
-#endif /* WIN32 */
+#endif /* _WIN32 */
/*
int num_values);
static void ipp_free_values(ipp_attribute_t *attr, int element,
int count);
-static char *ipp_get_code(const char *locale, char *buffer,
- size_t bufsize)
- __attribute__((nonnull(1,2)));
-static char *ipp_lang_code(const char *locale, char *buffer,
- size_t bufsize)
- __attribute__((nonnull(1,2)));
+static char *ipp_get_code(const char *locale, char *buffer, size_t bufsize) _CUPS_NONNULL(1,2);
+static char *ipp_lang_code(const char *locale, char *buffer, size_t bufsize) _CUPS_NONNULL(1,2);
static size_t ipp_length(ipp_t *ipp, int collection);
static ssize_t ipp_read_http(http_t *http, ipp_uchar_t *buffer,
size_t length);
int quickcopy) /* I - 1 for a referenced copy, 0 for normal */
{
int i; /* Looping var */
+ ipp_tag_t srctag; /* Source value tag */
ipp_attribute_t *dstattr; /* Destination attribute */
_ipp_value_t *srcval, /* Source value */
*dstval; /* Destination value */
* Copy it...
*/
- quickcopy = quickcopy ? IPP_TAG_CUPS_CONST : 0;
+ quickcopy = (quickcopy && (srcattr->value_tag & IPP_TAG_CUPS_CONST)) ? IPP_TAG_CUPS_CONST : 0;
+ srctag = srcattr->value_tag & IPP_TAG_CUPS_MASK;
- switch (srcattr->value_tag & ~IPP_TAG_CUPS_CONST)
+ switch (srctag)
{
case IPP_TAG_ZERO :
dstattr = ippAddSeparator(dst);
case IPP_TAG_NOTSETTABLE :
case IPP_TAG_DELETEATTR :
case IPP_TAG_ADMINDEFINE :
- dstattr = ippAddOutOfBand(dst, srcattr->group_tag, srcattr->value_tag & ~IPP_TAG_CUPS_CONST, srcattr->name);
+ dstattr = ippAddOutOfBand(dst, srcattr->group_tag, srctag, srcattr->name);
break;
case IPP_TAG_INTEGER :
case IPP_TAG_ENUM :
- dstattr = ippAddIntegers(dst, srcattr->group_tag, srcattr->value_tag,
- srcattr->name, srcattr->num_values, NULL);
- if (!dstattr)
- break;
-
- for (i = srcattr->num_values, srcval = srcattr->values, dstval = dstattr->values;
- i > 0;
- i --, srcval ++, dstval ++)
- dstval->integer = srcval->integer;
- break;
-
case IPP_TAG_BOOLEAN :
- dstattr = ippAddBooleans(dst, srcattr->group_tag, srcattr->name,
- srcattr->num_values, NULL);
- if (!dstattr)
- break;
-
- for (i = srcattr->num_values, srcval = srcattr->values, dstval = dstattr->values;
- i > 0;
- i --, srcval ++, dstval ++)
- dstval->boolean = srcval->boolean;
+ case IPP_TAG_DATE :
+ case IPP_TAG_RESOLUTION :
+ case IPP_TAG_RANGE :
+ if ((dstattr = ipp_add_attr(dst, srcattr->name, srcattr->group_tag, srctag, srcattr->num_values)) != NULL)
+ memcpy(dstattr->values, srcattr->values, (size_t)srcattr->num_values * sizeof(_ipp_value_t));
break;
case IPP_TAG_TEXT :
case IPP_TAG_NAME :
+ case IPP_TAG_RESERVED_STRING :
case IPP_TAG_KEYWORD :
case IPP_TAG_URI :
case IPP_TAG_URISCHEME :
case IPP_TAG_CHARSET :
case IPP_TAG_LANGUAGE :
case IPP_TAG_MIMETYPE :
- dstattr = ippAddStrings(dst, srcattr->group_tag,
- (ipp_tag_t)(srcattr->value_tag | quickcopy),
- srcattr->name, srcattr->num_values, NULL, NULL);
- if (!dstattr)
+ if ((dstattr = ippAddStrings(dst, srcattr->group_tag, (ipp_tag_t)(srctag | quickcopy), srcattr->name, srcattr->num_values, NULL, NULL)) == NULL)
break;
if (quickcopy)
{
- for (i = srcattr->num_values, srcval = srcattr->values,
- dstval = dstattr->values;
- i > 0;
- i --, srcval ++, dstval ++)
- dstval->string.text = srcval->string.text;
+ /*
+ * Can safely quick-copy these string values...
+ */
+
+ memcpy(dstattr->values, srcattr->values, (size_t)srcattr->num_values * sizeof(_ipp_value_t));
}
- else if (srcattr->value_tag & IPP_TAG_CUPS_CONST)
- {
- for (i = srcattr->num_values, srcval = srcattr->values,
- dstval = dstattr->values;
- i > 0;
- i --, srcval ++, dstval ++)
- dstval->string.text = _cupsStrAlloc(srcval->string.text);
- }
else
{
- for (i = srcattr->num_values, srcval = srcattr->values,
- dstval = dstattr->values;
- i > 0;
- i --, srcval ++, dstval ++)
- dstval->string.text = _cupsStrRetain(srcval->string.text);
- }
- break;
-
- case IPP_TAG_DATE :
- if (srcattr->num_values != 1)
- return (NULL);
-
- dstattr = ippAddDate(dst, srcattr->group_tag, srcattr->name,
- srcattr->values[0].date);
- break;
-
- case IPP_TAG_RESOLUTION :
- dstattr = ippAddResolutions(dst, srcattr->group_tag, srcattr->name,
- srcattr->num_values, IPP_RES_PER_INCH,
- NULL, NULL);
- if (!dstattr)
- break;
-
- for (i = srcattr->num_values, srcval = srcattr->values, dstval = dstattr->values;
- i > 0;
- i --, srcval ++, dstval ++)
- {
- dstval->resolution.xres = srcval->resolution.xres;
- dstval->resolution.yres = srcval->resolution.yres;
- dstval->resolution.units = srcval->resolution.units;
- }
- break;
-
- case IPP_TAG_RANGE :
- dstattr = ippAddRanges(dst, srcattr->group_tag, srcattr->name,
- srcattr->num_values, NULL, NULL);
- if (!dstattr)
- break;
+ /*
+ * Otherwise do a normal reference counted copy...
+ */
- for (i = srcattr->num_values, srcval = srcattr->values, dstval = dstattr->values;
- i > 0;
- i --, srcval ++, dstval ++)
- {
- dstval->range.lower = srcval->range.lower;
- dstval->range.upper = srcval->range.upper;
+ for (i = srcattr->num_values, srcval = srcattr->values, dstval = dstattr->values; i > 0; i --, srcval ++, dstval ++)
+ dstval->string.text = _cupsStrAlloc(srcval->string.text);
}
break;
case IPP_TAG_TEXTLANG :
case IPP_TAG_NAMELANG :
- dstattr = ippAddStrings(dst, srcattr->group_tag,
- (ipp_tag_t)(srcattr->value_tag | quickcopy),
- srcattr->name, srcattr->num_values, NULL, NULL);
- if (!dstattr)
+ if ((dstattr = ippAddStrings(dst, srcattr->group_tag, (ipp_tag_t)(srctag | quickcopy), srcattr->name, srcattr->num_values, NULL, NULL)) == NULL)
break;
if (quickcopy)
{
- for (i = srcattr->num_values, srcval = srcattr->values,
- dstval = dstattr->values;
- i > 0;
- i --, srcval ++, dstval ++)
- {
- dstval->string.language = srcval->string.language;
- dstval->string.text = srcval->string.text;
- }
+ /*
+ * Can safely quick-copy these string values...
+ */
+
+ memcpy(dstattr->values, srcattr->values, (size_t)srcattr->num_values * sizeof(_ipp_value_t));
}
else if (srcattr->value_tag & IPP_TAG_CUPS_CONST)
{
- for (i = srcattr->num_values, srcval = srcattr->values,
- dstval = dstattr->values;
- i > 0;
- i --, srcval ++, dstval ++)
+ /*
+ * Otherwise do a normal reference counted copy...
+ */
+
+ for (i = srcattr->num_values, srcval = srcattr->values, dstval = dstattr->values; i > 0; i --, srcval ++, dstval ++)
{
if (srcval == srcattr->values)
dstval->string.language = _cupsStrAlloc(srcval->string.language);
dstval->string.text = _cupsStrAlloc(srcval->string.text);
}
}
- else
- {
- for (i = srcattr->num_values, srcval = srcattr->values,
- dstval = dstattr->values;
- i > 0;
- i --, srcval ++, dstval ++)
- {
- if (srcval == srcattr->values)
- dstval->string.language = _cupsStrRetain(srcval->string.language);
- else
- dstval->string.language = dstattr->values[0].string.language;
-
- dstval->string.text = _cupsStrRetain(srcval->string.text);
- }
- }
break;
case IPP_TAG_BEGIN_COLLECTION :
- dstattr = ippAddCollections(dst, srcattr->group_tag, srcattr->name,
- srcattr->num_values, NULL);
- if (!dstattr)
+ if ((dstattr = ippAddCollections(dst, srcattr->group_tag, srcattr->name, srcattr->num_values, NULL)) == NULL)
break;
- for (i = srcattr->num_values, srcval = srcattr->values, dstval = dstattr->values;
- i > 0;
- i --, srcval ++, dstval ++)
+ for (i = srcattr->num_values, srcval = srcattr->values, dstval = dstattr->values; i > 0; i --, srcval ++, dstval ++)
{
dstval->collection = srcval->collection;
srcval->collection->use ++;
case IPP_TAG_STRING :
default :
- /* TODO: Implement quick copy for unknown/octetString values */
- dstattr = ippAddIntegers(dst, srcattr->group_tag, srcattr->value_tag,
- srcattr->name, srcattr->num_values, NULL);
- if (!dstattr)
+ if ((dstattr = ipp_add_attr(dst, srcattr->name, srcattr->group_tag, srctag, srcattr->num_values)) == NULL)
break;
- for (i = srcattr->num_values, srcval = srcattr->values, dstval = dstattr->values;
- i > 0;
- i --, srcval ++, dstval ++)
+ for (i = srcattr->num_values, srcval = srcattr->values, dstval = dstattr->values; i > 0; i --, srcval ++, dstval ++)
{
dstval->unknown.length = srcval->unknown.length;
ipp->use --;
if (ipp->use > 0)
+ {
+ DEBUG_printf(("4debug_retain: %p IPP message (use=%d)", (void *)ipp, ipp->use));
return;
+ }
+
+ DEBUG_printf(("4debug_free: %p IPP message", (void *)ipp));
for (attr = ipp->attrs; attr != NULL; attr = next)
{
next = attr->next;
+ DEBUG_printf(("4debug_free: %p %s %s%s (%d values)", (void *)attr, attr->name, attr->num_values > 1 ? "1setOf " : "", ippTagString(attr->value_tag), attr->num_values));
+
ipp_free_values(attr, 0, attr->num_values);
if (attr->name)
if (!attr)
return;
+ DEBUG_printf(("4debug_free: %p %s %s%s (%d values)", (void *)attr, attr->name, attr->num_values > 1 ? "1setOf " : "", ippTagString(attr->value_tag), attr->num_values));
+
/*
* Find the attribute in the list...
*/
* Set default version - usually 2.0...
*/
+ DEBUG_printf(("4debug_alloc: %p IPP message", (void *)temp));
+
if (cg->server_version == 0)
_cupsSetDefaults();
unsigned char *buffer, /* Data buffer */
string[IPP_MAX_TEXT],
/* Small string buffer */
- *bufptr; /* Pointer into buffer */
+ *bufptr, /* Pointer into buffer */
+ *bufend; /* End of buffer */
ipp_attribute_t *attr; /* Current attribute */
ipp_tag_t tag; /* Current tag */
ipp_tag_t value_tag; /* Current value tag */
* Read 32-bit "extension" tag...
*/
- if ((*cb)(src, buffer, 4) < 1)
+ if ((*cb)(src, buffer, 4) < 4)
{
DEBUG_puts("1ippReadIO: Callback returned EOF/error");
_cupsBufferRelease((char *)buffer);
ipp->state = IPP_STATE_DATA;
break;
}
+ else if (tag == IPP_TAG_ZERO || (tag == IPP_TAG_OPERATION && ipp->curtag != IPP_TAG_ZERO))
+ {
+ _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("Invalid group tag."), 1);
+ DEBUG_printf(("1ippReadIO: bad tag 0x%02x.", tag));
+ _cupsBufferRelease((char *)buffer);
+ return (IPP_STATE_ERROR);
+ }
else if (tag < IPP_TAG_UNSUPPORTED_VALUE)
{
/*
DEBUG_printf(("2ippReadIO: name length=%d", n));
- if (n == 0 && tag != IPP_TAG_MEMBERNAME &&
- tag != IPP_TAG_END_COLLECTION)
+ if (n && parent)
+ {
+ _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("Invalid named IPP attribute in collection."), 1);
+ DEBUG_puts("1ippReadIO: bad attribute name in collection.");
+ return (IPP_STATE_ERROR);
+ }
+ else if (n == 0 && tag != IPP_TAG_MEMBERNAME && tag != IPP_TAG_END_COLLECTION)
{
/*
* More values for current attribute...
value->boolean = (char)buffer[0];
break;
- case IPP_TAG_NOVALUE :
+ case IPP_TAG_UNSUPPORTED_VALUE :
+ case IPP_TAG_DEFAULT :
+ case IPP_TAG_UNKNOWN :
+ case IPP_TAG_NOVALUE :
case IPP_TAG_NOTSETTABLE :
case IPP_TAG_DELETEATTR :
case IPP_TAG_ADMINDEFINE :
case IPP_TAG_TEXT :
case IPP_TAG_NAME :
+ case IPP_TAG_RESERVED_STRING :
case IPP_TAG_KEYWORD :
case IPP_TAG_URI :
case IPP_TAG_URISCHEME :
}
bufptr = buffer;
+ bufend = buffer + n;
+
/*
* text-with-language and name-with-language are composite
n = (bufptr[0] << 8) | bufptr[1];
- if ((bufptr + 2 + n) >= (buffer + IPP_BUF_SIZE) || n >= (int)sizeof(string))
+ if ((bufptr + 2 + n) >= bufend || n >= (int)sizeof(string))
{
_cupsSetError(IPP_STATUS_ERROR_INTERNAL,
_("IPP language length overflows value."), 1);
value->string.language = _cupsStrAlloc((char *)string);
- bufptr += 2 + n;
+ bufptr += 2 + n;
n = (bufptr[0] << 8) | bufptr[1];
- if ((bufptr + 2 + n) >= (buffer + IPP_BUF_SIZE))
+ if ((bufptr + 2 + n) > bufend)
{
_cupsSetError(IPP_STATUS_ERROR_INTERNAL,
_("IPP string length overflows value."), 1);
DEBUG_printf(("2ippReadIO: member name=\"%s\"", attr->name));
break;
+ case IPP_TAG_STRING :
default : /* Other unsupported values */
if (tag == IPP_TAG_STRING && n > IPP_MAX_LENGTH)
{
* Range check input...
*/
- if (!ipp || !attr || !*attr || (*attr)->value_tag != IPP_TAG_DATE ||
- element < 0 || element > (*attr)->num_values || !datevalue)
+ if (!ipp || !attr || !*attr || ((*attr)->value_tag != IPP_TAG_DATE && (*attr)->value_tag != IPP_TAG_NOVALUE && (*attr)->value_tag != IPP_TAG_UNKNOWN) || element < 0 || element > (*attr)->num_values || !datevalue)
return (0);
/*
* Range check input...
*/
- if (!ipp || !attr || !*attr ||
- ((*attr)->value_tag != IPP_TAG_INTEGER && (*attr)->value_tag != IPP_TAG_ENUM) ||
- element < 0 || element > (*attr)->num_values)
+ if (!ipp || !attr || !*attr || ((*attr)->value_tag != IPP_TAG_INTEGER && (*attr)->value_tag != IPP_TAG_ENUM && (*attr)->value_tag != IPP_TAG_NOVALUE && (*attr)->value_tag != IPP_TAG_UNKNOWN) || element < 0 || element > (*attr)->num_values)
return (0);
/*
*/
if ((value = ipp_set_value(ipp, attr, element)) != NULL)
+ {
+ if ((*attr)->value_tag != IPP_TAG_ENUM)
+ (*attr)->value_tag = IPP_TAG_INTEGER;
+
value->integer = intvalue;
+ }
return (value != NULL);
}
* Range check input...
*/
- if (!ipp || !attr || !*attr || (*attr)->value_tag != IPP_TAG_STRING ||
- element < 0 || element > (*attr)->num_values ||
- datalen < 0 || datalen > IPP_MAX_LENGTH)
+ if (!ipp || !attr || !*attr || ((*attr)->value_tag != IPP_TAG_STRING && (*attr)->value_tag != IPP_TAG_NOVALUE && (*attr)->value_tag != IPP_TAG_UNKNOWN) || element < 0 || element > (*attr)->num_values || datalen < 0 || datalen > IPP_MAX_LENGTH)
return (0);
/*
* Copy the data...
*/
+ (*attr)->value_tag = IPP_TAG_STRING;
+
if (value->unknown.data)
{
/*
* Range check input...
*/
- if (!ipp || !attr || !*attr || (*attr)->value_tag != IPP_TAG_RANGE ||
- element < 0 || element > (*attr)->num_values || lowervalue > uppervalue)
+ if (!ipp || !attr || !*attr || ((*attr)->value_tag != IPP_TAG_RANGE && (*attr)->value_tag != IPP_TAG_NOVALUE && (*attr)->value_tag != IPP_TAG_UNKNOWN) || element < 0 || element > (*attr)->num_values || lowervalue > uppervalue)
return (0);
/*
if ((value = ipp_set_value(ipp, attr, element)) != NULL)
{
+ (*attr)->value_tag = IPP_TAG_RANGE;
value->range.lower = lowervalue;
value->range.upper = uppervalue;
}
* Range check input...
*/
- if (!ipp || !attr || !*attr || (*attr)->value_tag != IPP_TAG_RESOLUTION ||
- element < 0 || element > (*attr)->num_values || xresvalue <= 0 || yresvalue <= 0 ||
- unitsvalue < IPP_RES_PER_INCH || unitsvalue > IPP_RES_PER_CM)
+ if (!ipp || !attr || !*attr || ((*attr)->value_tag != IPP_TAG_RESOLUTION && (*attr)->value_tag != IPP_TAG_NOVALUE && (*attr)->value_tag != IPP_TAG_UNKNOWN) || element < 0 || element > (*attr)->num_values || xresvalue <= 0 || yresvalue <= 0 || unitsvalue < IPP_RES_PER_INCH || unitsvalue > IPP_RES_PER_CM)
return (0);
/*
if ((value = ipp_set_value(ipp, attr, element)) != NULL)
{
+ (*attr)->value_tag = IPP_TAG_RESOLUTION;
value->resolution.units = unitsvalue;
value->resolution.xres = xresvalue;
value->resolution.yres = yresvalue;
{
char *temp; /* Temporary string */
_ipp_value_t *value; /* Current value */
+ ipp_tag_t value_tag; /* Value tag */
/*
* Range check input...
*/
- if (!ipp || !attr || !*attr ||
- ((*attr)->value_tag != IPP_TAG_TEXTLANG &&
- (*attr)->value_tag != IPP_TAG_NAMELANG &&
- ((*attr)->value_tag < IPP_TAG_TEXT ||
- (*attr)->value_tag > IPP_TAG_MIMETYPE)) ||
- element < 0 || element > (*attr)->num_values || !strvalue)
+ if (attr && *attr)
+ value_tag = (*attr)->value_tag & IPP_TAG_CUPS_MASK;
+ else
+ value_tag = IPP_TAG_ZERO;
+
+ if (!ipp || !attr || !*attr || (value_tag < IPP_TAG_TEXT && value_tag != IPP_TAG_TEXTLANG && value_tag != IPP_TAG_NAMELANG && value_tag != IPP_TAG_NOVALUE && value_tag != IPP_TAG_UNKNOWN) || value_tag > IPP_TAG_MIMETYPE || element < 0 || element > (*attr)->num_values || !strvalue)
return (0);
/*
if ((value = ipp_set_value(ipp, attr, element)) != NULL)
{
+ if (value_tag == IPP_TAG_NOVALUE || value_tag == IPP_TAG_UNKNOWN)
+ (*attr)->value_tag = IPP_TAG_KEYWORD;
+
if (element > 0)
value->string.language = (*attr)->values[0].string.language;
else
value_tag = IPP_TAG_ZERO;
- if (!ipp || !attr || !*attr ||
- (value_tag < IPP_TAG_TEXT && value_tag != IPP_TAG_TEXTLANG &&
- value_tag != IPP_TAG_NAMELANG) || value_tag > IPP_TAG_MIMETYPE ||
- !format)
+ if (!ipp || !attr || !*attr || (value_tag < IPP_TAG_TEXT && value_tag != IPP_TAG_TEXTLANG && value_tag != IPP_TAG_NAMELANG && value_tag != IPP_TAG_NOVALUE && value_tag != IPP_TAG_UNKNOWN) || value_tag > IPP_TAG_MIMETYPE || !format)
return (0);
/*
max_bytes = IPP_MAX_CHARSET;
break;
+ case IPP_TAG_NOVALUE :
+ case IPP_TAG_UNKNOWN :
case IPP_TAG_KEYWORD :
max_bytes = IPP_MAX_KEYWORD;
break;
break;
case IPP_TAG_NAME :
- if (temp_tag != IPP_TAG_KEYWORD && temp_tag != IPP_TAG_URI &&
- temp_tag != IPP_TAG_URISCHEME && temp_tag != IPP_TAG_LANGUAGE &&
- temp_tag != IPP_TAG_MIMETYPE)
+ if (temp_tag != IPP_TAG_KEYWORD)
return (0);
(*attr)->value_tag = (ipp_tag_t)(IPP_TAG_NAME | ((*attr)->value_tag & IPP_TAG_CUPS_CONST));
case IPP_TAG_NAMELANG :
case IPP_TAG_TEXTLANG :
- if (value_tag == IPP_TAG_NAMELANG &&
- (temp_tag != IPP_TAG_NAME && temp_tag != IPP_TAG_KEYWORD &&
- temp_tag != IPP_TAG_URI && temp_tag != IPP_TAG_URISCHEME &&
- temp_tag != IPP_TAG_LANGUAGE && temp_tag != IPP_TAG_MIMETYPE))
+ if (value_tag == IPP_TAG_NAMELANG && (temp_tag != IPP_TAG_NAME && temp_tag != IPP_TAG_KEYWORD))
return (0);
if (value_tag == IPP_TAG_TEXTLANG && temp_tag != IPP_TAG_TEXT)
return (0);
if (ipp->attrs && ipp->attrs->next && ipp->attrs->next->name &&
- !strcmp(ipp->attrs->next->name, "attributes-natural-language"))
+ !strcmp(ipp->attrs->next->name, "attributes-natural-language") && (ipp->attrs->next->value_tag & IPP_TAG_CUPS_MASK) == IPP_TAG_LANGUAGE)
{
/*
* Use the language code from the IPP message...
const ipp_uchar_t * /* O - RFC-2579 date/time data */
ippTimeToDate(time_t t) /* I - Time in seconds */
{
- struct tm *unixdate; /* UNIX unixdate/time info */
+ struct tm unixdate; /* UNIX unixdate/time info */
ipp_uchar_t *date = _cupsGlobals()->ipp_date;
/* RFC-2579 date/time data */
* 10 UTC minutes (0 to 59)
*/
- unixdate = gmtime(&t);
- unixdate->tm_year += 1900;
+ gmtime_r(&t, &unixdate);
+ unixdate.tm_year += 1900;
- date[0] = (ipp_uchar_t)(unixdate->tm_year >> 8);
- date[1] = (ipp_uchar_t)(unixdate->tm_year);
- date[2] = (ipp_uchar_t)(unixdate->tm_mon + 1);
- date[3] = (ipp_uchar_t)unixdate->tm_mday;
- date[4] = (ipp_uchar_t)unixdate->tm_hour;
- date[5] = (ipp_uchar_t)unixdate->tm_min;
- date[6] = (ipp_uchar_t)unixdate->tm_sec;
+ date[0] = (ipp_uchar_t)(unixdate.tm_year >> 8);
+ date[1] = (ipp_uchar_t)(unixdate.tm_year);
+ date[2] = (ipp_uchar_t)(unixdate.tm_mon + 1);
+ date[3] = (ipp_uchar_t)unixdate.tm_mday;
+ date[4] = (ipp_uchar_t)unixdate.tm_hour;
+ date[5] = (ipp_uchar_t)unixdate.tm_min;
+ date[6] = (ipp_uchar_t)unixdate.tm_sec;
date[7] = 0;
date[8] = '+';
date[9] = 0;
ipp_attribute_t *colattr; /* Collection attribute */
regex_t re; /* Regular expression */
ipp_uchar_t *date; /* Current date value */
- static const char * const uri_status_strings[] =
- { /* URI status strings */
- "URI too large",
- "Bad arguments to function",
- "Bad resource in URI",
- "Bad port number in URI",
- "Bad hostname/address in URI",
- "Bad username in URI",
- "Bad scheme in URI",
- "Bad/empty URI",
- "OK",
- "Missing scheme in URI",
- "Unknown scheme in URI",
- "Missing resource in URI"
- };
/*
if (*ptr || ptr == attr->name)
{
- ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST,
- _("\"%s\": Bad attribute name - invalid character "
- "(RFC 8011 section 5.1.4)."), attr->name);
+ ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST, _("\"%s\": Bad attribute name - invalid character (RFC 8011 section 5.1.4)."), attr->name);
return (0);
}
if ((ptr - attr->name) > 255)
{
- ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST,
- _("\"%s\": Bad attribute name - bad length %d "
- "(RFC 8011 section 5.1.4)."), attr->name,
- (int)(ptr - attr->name));
+ ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST, _("\"%s\": Bad attribute name - bad length %d (RFC 8011 section 5.1.4)."), attr->name, (int)(ptr - attr->name));
return (0);
}
if (attr->values[i].boolean != 0 &&
attr->values[i].boolean != 1)
{
- ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST,
- _("\"%s\": Bad boolen value %d "
- "(RFC 8011 section 5.1.21)."), attr->name,
- attr->values[i].boolean);
+ ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST, _("\"%s\": Bad boolean value %d (RFC 8011 section 5.1.21)."), attr->name, attr->values[i].boolean);
return (0);
}
}
{
if (attr->values[i].integer < 1)
{
- ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST,
- _("\"%s\": Bad enum value %d - out of range "
- "(RFC 8011 section 5.1.5)."), attr->name,
- attr->values[i].integer);
+ ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST, _("\"%s\": Bad enum value %d - out of range (RFC 8011 section 5.1.5)."), attr->name, attr->values[i].integer);
return (0);
}
}
{
if (attr->values[i].unknown.length > IPP_MAX_OCTETSTRING)
{
- ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST,
- _("\"%s\": Bad octetString value - bad length %d "
- "(RFC 8011 section 5.1.20)."), attr->name,
- attr->values[i].unknown.length);
+ ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST, _("\"%s\": Bad octetString value - bad length %d (RFC 8011 section 5.1.20)."), attr->name, attr->values[i].unknown.length);
return (0);
}
}
if (date[2] < 1 || date[2] > 12)
{
- ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST,
- _("\"%s\": Bad dateTime month %u "
- "(RFC 8011 section 5.1.15)."), attr->name, date[2]);
+ ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST, _("\"%s\": Bad dateTime month %u (RFC 8011 section 5.1.15)."), attr->name, date[2]);
return (0);
}
if (date[3] < 1 || date[3] > 31)
{
- ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST,
- _("\"%s\": Bad dateTime day %u "
- "(RFC 8011 section 5.1.15)."), attr->name, date[3]);
+ ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST, _("\"%s\": Bad dateTime day %u (RFC 8011 section 5.1.15)."), attr->name, date[3]);
return (0);
}
if (date[4] > 23)
{
- ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST,
- _("\"%s\": Bad dateTime hours %u "
- "(RFC 8011 section 5.1.15)."), attr->name, date[4]);
+ ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST, _("\"%s\": Bad dateTime hours %u (RFC 8011 section 5.1.15)."), attr->name, date[4]);
return (0);
}
if (date[5] > 59)
{
- ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST,
- _("\"%s\": Bad dateTime minutes %u "
- "(RFC 8011 section 5.1.15)."), attr->name, date[5]);
+ ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST, _("\"%s\": Bad dateTime minutes %u (RFC 8011 section 5.1.15)."), attr->name, date[5]);
return (0);
}
if (date[6] > 60)
{
- ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST,
- _("\"%s\": Bad dateTime seconds %u "
- "(RFC 8011 section 5.1.15)."), attr->name, date[6]);
+ ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST, _("\"%s\": Bad dateTime seconds %u (RFC 8011 section 5.1.15)."), attr->name, date[6]);
return (0);
}
if (date[7] > 9)
{
- ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST,
- _("\"%s\": Bad dateTime deciseconds %u "
- "(RFC 8011 section 5.1.15)."), attr->name, date[7]);
+ ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST, _("\"%s\": Bad dateTime deciseconds %u (RFC 8011 section 5.1.15)."), attr->name, date[7]);
return (0);
}
if (date[8] != '-' && date[8] != '+')
{
- ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST,
- _("\"%s\": Bad dateTime UTC sign '%c' "
- "(RFC 8011 section 5.1.15)."), attr->name, date[8]);
+ ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST, _("\"%s\": Bad dateTime UTC sign '%c' (RFC 8011 section 5.1.15)."), attr->name, date[8]);
return (0);
}
if (date[9] > 11)
{
- ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST,
- _("\"%s\": Bad dateTime UTC hours %u "
- "(RFC 8011 section 5.1.15)."), attr->name, date[9]);
+ ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST, _("\"%s\": Bad dateTime UTC hours %u (RFC 8011 section 5.1.15)."), attr->name, date[9]);
return (0);
}
if (date[10] > 59)
{
- ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST,
- _("\"%s\": Bad dateTime UTC minutes %u "
- "(RFC 8011 section 5.1.15)."), attr->name, date[10]);
+ ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST, _("\"%s\": Bad dateTime UTC minutes %u (RFC 8011 section 5.1.15)."), attr->name, date[10]);
return (0);
}
}
{
if (attr->values[i].resolution.xres <= 0)
{
- ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST,
- _("\"%s\": Bad resolution value %dx%d%s - cross "
- "feed resolution must be positive "
- "(RFC 8011 section 5.1.16)."), attr->name,
- attr->values[i].resolution.xres,
- attr->values[i].resolution.yres,
- attr->values[i].resolution.units ==
- IPP_RES_PER_INCH ? "dpi" :
- attr->values[i].resolution.units ==
- IPP_RES_PER_CM ? "dpcm" : "unknown");
+ ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST, _("\"%s\": Bad resolution value %dx%d%s - cross feed resolution must be positive (RFC 8011 section 5.1.16)."), attr->name, attr->values[i].resolution.xres, attr->values[i].resolution.yres, attr->values[i].resolution.units == IPP_RES_PER_INCH ? "dpi" : attr->values[i].resolution.units == IPP_RES_PER_CM ? "dpcm" : "unknown");
return (0);
}
if (attr->values[i].resolution.yres <= 0)
{
- ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST,
- _("\"%s\": Bad resolution value %dx%d%s - feed "
- "resolution must be positive "
- "(RFC 8011 section 5.1.16)."), attr->name,
- attr->values[i].resolution.xres,
- attr->values[i].resolution.yres,
- attr->values[i].resolution.units ==
- IPP_RES_PER_INCH ? "dpi" :
- attr->values[i].resolution.units ==
- IPP_RES_PER_CM ? "dpcm" : "unknown");
+ ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST, _("\"%s\": Bad resolution value %dx%d%s - feed resolution must be positive (RFC 8011 section 5.1.16)."), attr->name, attr->values[i].resolution.xres, attr->values[i].resolution.yres, attr->values[i].resolution.units == IPP_RES_PER_INCH ? "dpi" : attr->values[i].resolution.units == IPP_RES_PER_CM ? "dpcm" : "unknown");
return (0);
}
- if (attr->values[i].resolution.units != IPP_RES_PER_INCH &&
- attr->values[i].resolution.units != IPP_RES_PER_CM)
+ if (attr->values[i].resolution.units != IPP_RES_PER_INCH && attr->values[i].resolution.units != IPP_RES_PER_CM)
{
- ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST,
- _("\"%s\": Bad resolution value %dx%d%s - bad "
- "units value (RFC 8011 section 5.1.16)."),
- attr->name, attr->values[i].resolution.xres,
- attr->values[i].resolution.yres,
- attr->values[i].resolution.units ==
- IPP_RES_PER_INCH ? "dpi" :
- attr->values[i].resolution.units ==
- IPP_RES_PER_CM ? "dpcm" : "unknown");
+ ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST, _("\"%s\": Bad resolution value %dx%d%s - bad units value (RFC 8011 section 5.1.16)."), attr->name, attr->values[i].resolution.xres, attr->values[i].resolution.yres, attr->values[i].resolution.units == IPP_RES_PER_INCH ? "dpi" : attr->values[i].resolution.units == IPP_RES_PER_CM ? "dpcm" : "unknown");
return (0);
}
}
{
if (attr->values[i].range.lower > attr->values[i].range.upper)
{
- ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST,
- _("\"%s\": Bad rangeOfInteger value %d-%d - lower "
- "greater than upper (RFC 8011 section 5.1.14)."),
- attr->name, attr->values[i].range.lower,
- attr->values[i].range.upper);
+ ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST, _("\"%s\": Bad rangeOfInteger value %d-%d - lower greater than upper (RFC 8011 section 5.1.14)."), attr->name, attr->values[i].range.lower, attr->values[i].range.upper);
return (0);
}
}
{
if ((*ptr & 0xe0) == 0xc0)
{
- ptr ++;
- if ((*ptr & 0xc0) != 0x80)
+ if ((ptr[1] & 0xc0) != 0x80)
break;
+
+ ptr ++;
}
else if ((*ptr & 0xf0) == 0xe0)
{
- ptr ++;
- if ((*ptr & 0xc0) != 0x80)
- break;
- ptr ++;
- if ((*ptr & 0xc0) != 0x80)
+ if ((ptr[1] & 0xc0) != 0x80 || (ptr[2] & 0xc0) != 0x80)
break;
+
+ ptr += 2;
}
else if ((*ptr & 0xf8) == 0xf0)
{
- ptr ++;
- if ((*ptr & 0xc0) != 0x80)
- break;
- ptr ++;
- if ((*ptr & 0xc0) != 0x80)
- break;
- ptr ++;
- if ((*ptr & 0xc0) != 0x80)
+ if ((ptr[1] & 0xc0) != 0x80 || (ptr[2] & 0xc0) != 0x80 || (ptr[3] & 0xc0) != 0x80)
break;
+
+ ptr += 3;
}
else if (*ptr & 0x80)
break;
+ else if ((*ptr < ' ' && *ptr != '\n' && *ptr != '\r' && *ptr != '\t') || *ptr == 0x7f)
+ break;
}
- if (*ptr)
- {
- ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST,
- _("\"%s\": Bad text value \"%s\" - bad UTF-8 "
- "sequence (RFC 8011 section 5.1.2)."), attr->name,
- attr->values[i].string.text);
- return (0);
- }
+ if (*ptr)
+ {
+ if (*ptr < ' ' || *ptr == 0x7f)
+ {
+ ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST, _("\"%s\": Bad text value \"%s\" - bad control character (PWG 5100.14 section 8.3)."), attr->name, attr->values[i].string.text);
+ return (0);
+ }
+ else
+ {
+ ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST, _("\"%s\": Bad text value \"%s\" - bad UTF-8 sequence (RFC 8011 section 5.1.2)."), attr->name, attr->values[i].string.text);
+ return (0);
+ }
+ }
if ((ptr - attr->values[i].string.text) > (IPP_MAX_TEXT - 1))
{
- ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST,
- _("\"%s\": Bad text value \"%s\" - bad length %d "
- "(RFC 8011 section 5.1.2)."), attr->name,
- attr->values[i].string.text,
- (int)(ptr - attr->values[i].string.text));
+ ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST, _("\"%s\": Bad text value \"%s\" - bad length %d (RFC 8011 section 5.1.2)."), attr->name, attr->values[i].string.text, (int)(ptr - attr->values[i].string.text));
return (0);
}
}
{
if ((*ptr & 0xe0) == 0xc0)
{
- ptr ++;
- if ((*ptr & 0xc0) != 0x80)
+ if ((ptr[1] & 0xc0) != 0x80)
break;
+
+ ptr ++;
}
else if ((*ptr & 0xf0) == 0xe0)
{
- ptr ++;
- if ((*ptr & 0xc0) != 0x80)
- break;
- ptr ++;
- if ((*ptr & 0xc0) != 0x80)
+ if ((ptr[1] & 0xc0) != 0x80 || (ptr[2] & 0xc0) != 0x80)
break;
+
+ ptr += 2;
}
else if ((*ptr & 0xf8) == 0xf0)
{
- ptr ++;
- if ((*ptr & 0xc0) != 0x80)
- break;
- ptr ++;
- if ((*ptr & 0xc0) != 0x80)
- break;
- ptr ++;
- if ((*ptr & 0xc0) != 0x80)
+ if ((ptr[1] & 0xc0) != 0x80 || (ptr[2] & 0xc0) != 0x80 || (ptr[3] & 0xc0) != 0x80)
break;
+
+ ptr += 3;
}
else if (*ptr & 0x80)
break;
+ else if (*ptr < ' ' || *ptr == 0x7f)
+ break;
}
if (*ptr)
{
- ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST,
- _("\"%s\": Bad name value \"%s\" - bad UTF-8 "
- "sequence (RFC 8011 section 5.1.3)."), attr->name,
- attr->values[i].string.text);
- return (0);
- }
+ if (*ptr < ' ' || *ptr == 0x7f)
+ {
+ ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST, _("\"%s\": Bad name value \"%s\" - bad control character (PWG 5100.14 section 8.1)."), attr->name, attr->values[i].string.text);
+ return (0);
+ }
+ else
+ {
+ ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST, _("\"%s\": Bad name value \"%s\" - bad UTF-8 sequence (RFC 8011 section 5.1.3)."), attr->name, attr->values[i].string.text);
+ return (0);
+ }
+ }
if ((ptr - attr->values[i].string.text) > (IPP_MAX_NAME - 1))
{
- ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST,
- _("\"%s\": Bad name value \"%s\" - bad length %d "
- "(RFC 8011 section 5.1.3)."), attr->name,
- attr->values[i].string.text,
- (int)(ptr - attr->values[i].string.text));
+ ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST, _("\"%s\": Bad name value \"%s\" - bad length %d (RFC 8011 section 5.1.3)."), attr->name, attr->values[i].string.text, (int)(ptr - attr->values[i].string.text));
return (0);
}
}
for (i = 0; i < attr->num_values; i ++)
{
for (ptr = attr->values[i].string.text; *ptr; ptr ++)
+ {
if (!isalnum(*ptr & 255) && *ptr != '-' && *ptr != '.' &&
*ptr != '_')
break;
+ }
if (*ptr || ptr == attr->values[i].string.text)
{
- ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST,
- _("\"%s\": Bad keyword value \"%s\" - invalid "
- "character (RFC 8011 section 5.1.4)."),
- attr->name, attr->values[i].string.text);
+ ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST, _("\"%s\": Bad keyword value \"%s\" - invalid character (RFC 8011 section 5.1.4)."), attr->name, attr->values[i].string.text);
return (0);
}
if ((ptr - attr->values[i].string.text) > (IPP_MAX_KEYWORD - 1))
{
- ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST,
- _("\"%s\": Bad keyword value \"%s\" - bad "
- "length %d (RFC 8011 section 5.1.4)."),
- attr->name, attr->values[i].string.text,
- (int)(ptr - attr->values[i].string.text));
+ ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST, _("\"%s\": Bad keyword value \"%s\" - bad length %d (RFC 8011 section 5.1.4)."), attr->name, attr->values[i].string.text, (int)(ptr - attr->values[i].string.text));
return (0);
}
}
case IPP_TAG_URI :
for (i = 0; i < attr->num_values; i ++)
{
- uri_status = httpSeparateURI(HTTP_URI_CODING_ALL,
- attr->values[i].string.text,
- scheme, sizeof(scheme),
- userpass, sizeof(userpass),
- hostname, sizeof(hostname),
- &port, resource, sizeof(resource));
+ uri_status = httpSeparateURI(HTTP_URI_CODING_ALL, attr->values[i].string.text, scheme, sizeof(scheme), userpass, sizeof(userpass), hostname, sizeof(hostname), &port, resource, sizeof(resource));
if (uri_status < HTTP_URI_STATUS_OK)
{
- ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST,
- _("\"%s\": Bad URI value \"%s\" - %s "
- "(RFC 8011 section 5.1.6)."), attr->name,
- attr->values[i].string.text,
- uri_status_strings[uri_status -
- HTTP_URI_STATUS_OVERFLOW]);
+ ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST, _("\"%s\": Bad URI value \"%s\" - %s (RFC 8011 section 5.1.6)."), attr->name, attr->values[i].string.text, httpURIStatusString(uri_status));
return (0);
}
if (strlen(attr->values[i].string.text) > (IPP_MAX_URI - 1))
{
- ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST,
- _("\"%s\": Bad URI value \"%s\" - bad length %d "
- "(RFC 8011 section 5.1.6)."), attr->name,
- attr->values[i].string.text,
- (int)strlen(attr->values[i].string.text));
+ ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST, _("\"%s\": Bad URI value \"%s\" - bad length %d (RFC 8011 section 5.1.6)."), attr->name, attr->values[i].string.text, (int)strlen(attr->values[i].string.text));
}
}
break;
if (islower(*ptr & 255))
{
for (ptr ++; *ptr; ptr ++)
+ {
if (!islower(*ptr & 255) && !isdigit(*ptr & 255) &&
*ptr != '+' && *ptr != '-' && *ptr != '.')
break;
+ }
}
if (*ptr || ptr == attr->values[i].string.text)
{
- ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST,
- _("\"%s\": Bad uriScheme value \"%s\" - bad "
- "characters (RFC 8011 section 5.1.7)."),
- attr->name, attr->values[i].string.text);
+ ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST, _("\"%s\": Bad uriScheme value \"%s\" - bad characters (RFC 8011 section 5.1.7)."), attr->name, attr->values[i].string.text);
return (0);
}
if ((ptr - attr->values[i].string.text) > (IPP_MAX_URISCHEME - 1))
{
- ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST,
- _("\"%s\": Bad uriScheme value \"%s\" - bad "
- "length %d (RFC 8011 section 5.1.7)."),
- attr->name, attr->values[i].string.text,
- (int)(ptr - attr->values[i].string.text));
+ ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST, _("\"%s\": Bad uriScheme value \"%s\" - bad length %d (RFC 8011 section 5.1.7)."), attr->name, attr->values[i].string.text, (int)(ptr - attr->values[i].string.text));
return (0);
}
}
for (i = 0; i < attr->num_values; i ++)
{
for (ptr = attr->values[i].string.text; *ptr; ptr ++)
+ {
if (!isprint(*ptr & 255) || isupper(*ptr & 255) ||
isspace(*ptr & 255))
break;
+ }
if (*ptr || ptr == attr->values[i].string.text)
{
- ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST,
- _("\"%s\": Bad charset value \"%s\" - bad "
- "characters (RFC 8011 section 5.1.8)."),
- attr->name, attr->values[i].string.text);
+ ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST, _("\"%s\": Bad charset value \"%s\" - bad characters (RFC 8011 section 5.1.8)."), attr->name, attr->values[i].string.text);
return (0);
}
if ((ptr - attr->values[i].string.text) > (IPP_MAX_CHARSET - 1))
{
- ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST,
- _("\"%s\": Bad charset value \"%s\" - bad "
- "length %d (RFC 8011 section 5.1.8)."),
- attr->name, attr->values[i].string.text,
- (int)(ptr - attr->values[i].string.text));
+ ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST, _("\"%s\": Bad charset value \"%s\" - bad length %d (RFC 8011 section 5.1.8)."), attr->name, attr->values[i].string.text, (int)(ptr - attr->values[i].string.text));
return (0);
}
}
char temp[256]; /* Temporary error string */
regerror(i, &re, temp, sizeof(temp));
- ipp_set_error(IPP_STATUS_ERROR_INTERNAL,
- _("Unable to compile naturalLanguage regular "
- "expression: %s."), temp);
+ ipp_set_error(IPP_STATUS_ERROR_INTERNAL, _("Unable to compile naturalLanguage regular expression: %s."), temp);
return (0);
}
{
if (regexec(&re, attr->values[i].string.text, 0, NULL, 0))
{
- ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST,
- _("\"%s\": Bad naturalLanguage value \"%s\" - bad "
- "characters (RFC 8011 section 5.1.9)."),
- attr->name, attr->values[i].string.text);
+ ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST, _("\"%s\": Bad naturalLanguage value \"%s\" - bad characters (RFC 8011 section 5.1.9)."), attr->name, attr->values[i].string.text);
regfree(&re);
return (0);
}
if (strlen(attr->values[i].string.text) > (IPP_MAX_LANGUAGE - 1))
{
- ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST,
- _("\"%s\": Bad naturalLanguage value \"%s\" - bad "
- "length %d (RFC 8011 section 5.1.9)."),
- attr->name, attr->values[i].string.text,
- (int)strlen(attr->values[i].string.text));
+ ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST, _("\"%s\": Bad naturalLanguage value \"%s\" - bad length %d (RFC 8011 section 5.1.9)."), attr->name, attr->values[i].string.text, (int)strlen(attr->values[i].string.text));
regfree(&re);
return (0);
}
char temp[256]; /* Temporary error string */
regerror(i, &re, temp, sizeof(temp));
- ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST,
- _("Unable to compile mimeMediaType regular "
- "expression: %s."), temp);
+ ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST, _("Unable to compile mimeMediaType regular expression: %s."), temp);
return (0);
}
{
if (regexec(&re, attr->values[i].string.text, 0, NULL, 0))
{
- ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST,
- _("\"%s\": Bad mimeMediaType value \"%s\" - bad "
- "characters (RFC 8011 section 5.1.10)."),
- attr->name, attr->values[i].string.text);
+ ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST, _("\"%s\": Bad mimeMediaType value \"%s\" - bad characters (RFC 8011 section 5.1.10)."), attr->name, attr->values[i].string.text);
regfree(&re);
return (0);
}
if (strlen(attr->values[i].string.text) > (IPP_MAX_MIMETYPE - 1))
{
- ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST,
- _("\"%s\": Bad mimeMediaType value \"%s\" - bad "
- "length %d (RFC 8011 section 5.1.10)."),
- attr->name, attr->values[i].string.text,
- (int)strlen(attr->values[i].string.text));
+ ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST, _("\"%s\": Bad mimeMediaType value \"%s\" - bad length %d (RFC 8011 section 5.1.10)."), attr->name, attr->values[i].string.text, (int)strlen(attr->values[i].string.text));
regfree(&re);
return (0);
}
* Initialize attribute...
*/
+ DEBUG_printf(("4debug_alloc: %p %s %s%s (%d values)", (void *)attr, name, num_values > 1 ? "1setOf " : "", ippTagString(value_tag), num_values));
+
if (name)
attr->name = _cupsStrAlloc(name);
}
break;
+ case IPP_TAG_UNSUPPORTED_VALUE :
case IPP_TAG_DEFAULT :
case IPP_TAG_UNKNOWN :
case IPP_TAG_NOVALUE :
if ((bytes = httpRead2(http, (char *)buffer, length - (size_t)tbytes)) < 0)
{
-#ifdef WIN32
+#ifdef _WIN32
break;
#else
if (errno != EAGAIN && errno != EINTR)
break;
bytes = 0;
-#endif /* WIN32 */
+#endif /* _WIN32 */
}
else if (bytes == 0)
break;
ipp_uchar_t *buffer, /* O - Read buffer */
size_t length) /* I - Number of bytes to read */
{
-#ifdef WIN32
+#ifdef _WIN32
return ((ssize_t)read(*fd, buffer, (unsigned)length));
#else
return (read(*fd, buffer, length));
-#endif /* WIN32 */
+#endif /* _WIN32 */
}
* Reset pointers in the list...
*/
+#ifndef __clang_analyzer__
+ DEBUG_printf(("4debug_free: %p %s", (void *)*attr, temp->name));
+#endif /* !__clang_analyzer__ */
+ DEBUG_printf(("4debug_alloc: %p %s %s%s (%d)", (void *)temp, temp->name, temp->num_values > 1 ? "1setOf " : "", ippTagString(temp->value_tag), temp->num_values));
+
if (ipp->current == *attr && ipp->prev)
{
/*
ipp_uchar_t *buffer, /* I - Data to write */
size_t length) /* I - Number of bytes to write */
{
-#ifdef WIN32
+#ifdef _WIN32
return ((ssize_t)write(*fd, buffer, (unsigned)length));
#else
return (write(*fd, buffer, length));
-#endif /* WIN32 */
+#endif /* _WIN32 */
}