From: Michael Sweet Date: Thu, 13 Oct 2016 13:58:42 +0000 (-0400) Subject: The cups-lpd program did not catch all legacy usage of ISO-8859-1 (Issue #4899) X-Git-Tag: v2.2.2~70 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5babee86cb84055bce3597ab537abe4a6c6d8dbc;p=thirdparty%2Fcups.git The cups-lpd program did not catch all legacy usage of ISO-8859-1 (Issue #4899) --- diff --git a/CHANGES.txt b/CHANGES.txt index 1b3dcdee14..53a4640b7a 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,6 +1,12 @@ -CHANGES.txt - 2.2.1 - 2016-10-03 +CHANGES.txt - 2.2.2 - 2016-10-13 -------------------------------- +CHANGES IN CUPS V2.2.2 + + - The cups-lpd program did not catch all legacy usage of ISO-8859-1 + (Issue #4899) + + CHANGES IN CUPS V2.2.1 - Added "CreateSelfSignedCerts" directive for cups-files.conf to diff --git a/doc/help/man-backend.html b/doc/help/man-backend.html index 156717b460..1a21972857 100644 --- a/doc/help/man-backend.html +++ b/doc/help/man-backend.html @@ -61,7 +61,7 @@ function may be used to retrieve the correct device URI.

Backends are responsible for reading side-channel requests using the cupsSideChannelRead() function and responding with the -cupsSideChannelWrite() +cupsSideChannelWrite() function. The CUPS_SC_FD constant defines the file descriptor that should be monitored for incoming requests. @@ -147,7 +147,7 @@ CUPS backends can expect the following environment variable:

Files

/etc/cups/cups-files.conf

Notes

-CUPS backends are not generally design to be run directly by the user. Aside from the device URI issue ( +CUPS backends are not generally designed to be run directly by the user. Aside from the device URI issue ( argv[0] and DEVICE_URI diff --git a/scheduler/cups-lpd.c b/scheduler/cups-lpd.c index 16b8c23fd0..50aae4fb25 100644 --- a/scheduler/cups-lpd.c +++ b/scheduler/cups-lpd.c @@ -1650,16 +1650,24 @@ smart_strlcpy(char *dst, /* I - Output buffer */ *dstptr++ = 0xc0 | (*srcptr >> 6); *dstptr++ = 0x80 | (*srcptr++ & 0x3f); } - else if ((*srcptr & 0xe0) == 0xc0) + else if ((*srcptr & 0xe0) == 0xc0 && (srcptr[1] & 0xc0) == 0x80) { + /* + * 2-byte UTF-8 sequence... + */ + if (dstptr > (dstend - 2)) break; *dstptr++ = *srcptr++; *dstptr++ = *srcptr++; } - else if ((*srcptr & 0xf0) == 0xe0) + else if ((*srcptr & 0xf0) == 0xe0 && (srcptr[1] & 0xc0) == 0x80 && (srcptr[2] & 0xc0) == 0x80) { + /* + * 3-byte UTF-8 sequence... + */ + if (dstptr > (dstend - 3)) break; @@ -1667,8 +1675,12 @@ smart_strlcpy(char *dst, /* I - Output buffer */ *dstptr++ = *srcptr++; *dstptr++ = *srcptr++; } - else if ((*srcptr & 0xf8) == 0xf0) + else if ((*srcptr & 0xf8) == 0xf0 && (srcptr[1] & 0xc0) == 0x80 && (srcptr[2] & 0xc0) == 0x80 && (srcptr[3] & 0xc0) == 0x80) { + /* + * 4-byte UTF-8 sequence... + */ + if (dstptr > (dstend - 4)) break; @@ -1680,7 +1692,7 @@ smart_strlcpy(char *dst, /* I - Output buffer */ else { /* - * Orphan UTF-8 sequence, this must be an ISO-8859-1 string... + * Bad UTF-8 sequence, this must be an ISO-8859-1 string... */ saw_8859 = 1;