summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTill Kamppeter <till.kamppeter@gmail.com>2016-08-09 18:11:28 +0200
committerDidier Raboud <odyx@debian.org>2018-06-08 15:06:24 +0200
commit3d7e18de483839524ec3412f4cd906d88ea036e8 (patch)
treea213dc1ef52c463b91f0cda751c05f0732c4dde7
parent25b6c1835a1e28df0fc8a83db31959384333714c (diff)
Some printers have broken device IDs with newline
characters inside. These break the cups-deviced printer discovery mechanism and so the printers get ignored. This patch allows newline characters in device IDs Bug-Ubuntu: https://bugs.launchpad.net/bugs/468701 Bug: https://www.cups.org/str.php?L4345 Last-Update: 2015-02-10 Patch-Name: cups-deviced-allow-device-ids-with-newline.patch
-rw-r--r--scheduler/cups-deviced.c23
1 files changed, 19 insertions, 4 deletions
diff --git a/scheduler/cups-deviced.c b/scheduler/cups-deviced.c
index 0d3ee0b89..5fcc5b1cd 100644
--- a/scheduler/cups-deviced.c
+++ b/scheduler/cups-deviced.c
@@ -558,15 +558,30 @@ get_device(cupsd_backend_t *backend) /* I - Backend to read from */
if (*ptr == '\"')
{
- for (ptr ++, device_id = ptr; *ptr && *ptr != '\"'; ptr ++)
+ for (ptr ++, device_id = ptr; *ptr != '\"'; ptr ++)
{
if (*ptr == '\\' && ptr[1])
_cups_strcpy(ptr, ptr + 1);
+ if (!*ptr)
+ {
+ fprintf(stderr, "WARNING: [cups-deviced] Possible newline in device ID \"%s\": %s\n",
+ backend->name, line);
+ *ptr = ' ';
+ ptr ++;
+ *ptr = 0;
+ if (!cupsFileGets(backend->pipe, ptr, sizeof(line) - (ptr - temp)))
+ {
+ cupsFileClose(backend->pipe);
+ backend->pipe = NULL;
+ fprintf(stderr, "ERROR: [cups-deviced] Bad line from \"%s\": %s\n",
+ backend->name, line);
+ return (-1);
+ }
+ }
+ if (!*ptr)
+ goto error;
}
- if (*ptr != '\"')
- goto error;
-
for (*ptr++ = '\0'; isspace(*ptr & 255); *ptr++ = '\0');
/*