From cc87cd1cc3688af8f7c578e377f447de7943fc6a Mon Sep 17 00:00:00 2001 From: Solomon Peachy Date: Thu, 20 Aug 2015 23:22:35 -0400 Subject: [PATCH] all: Add some print quantity range checks where we can. Most backends don't verify against remaining media though. --- backend_citizencw01.c | 3 ++- backend_dnpds40.c | 2 ++ backend_kodak605.c | 2 ++ backend_kodak6800.c | 2 ++ backend_shinkos1245.c | 4 ++++ backend_shinkos2145.c | 4 +++- backend_shinkos6145.c | 2 ++ backend_shinkos6245.c | 2 ++ 8 files changed, 19 insertions(+), 2 deletions(-) diff --git a/backend_citizencw01.c b/backend_citizencw01.c index f418ff2..8148618 100644 --- a/backend_citizencw01.c +++ b/backend_citizencw01.c @@ -445,7 +445,8 @@ top: free(resp); resp = NULL; - /* Set print quantity */ + /* Set print quantity */ // XXX check against remaining print count + cw01_build_cmd(&cmd, "CNTRL", "QTY", 8); snprintf(buf, sizeof(buf), "%07d\r", copies); ret = cw01_do_cmd(ctx, &cmd, (uint8_t*) buf, 8); diff --git a/backend_dnpds40.c b/backend_dnpds40.c index 737f9cc..4b670df 100644 --- a/backend_dnpds40.c +++ b/backend_dnpds40.c @@ -795,6 +795,8 @@ static int dnpds40_main_loop(void *vctx, int copies) { return CUPS_BACKEND_FAILED; /* Update quantity offset with count */ + // XXX this breaks if ctx->manual_copies is set, but the job + // has a CNTRL QTY != 1 if (!ctx->manual_copies && copies > 1) { snprintf(buf, sizeof(buf), "%07d\r", copies); if (ctx->qty_offset) { diff --git a/backend_kodak605.c b/backend_kodak605.c index 579f1da..0c2386b 100644 --- a/backend_kodak605.c +++ b/backend_kodak605.c @@ -299,6 +299,8 @@ static int kodak605_main_loop(void *vctx, int copies) { return CUPS_BACKEND_FAILED; /* Printer handles generating copies.. */ + if (copies > 255) + copies = 255; if (ctx->hdr.copies < copies) ctx->hdr.copies = copies; diff --git a/backend_kodak6800.c b/backend_kodak6800.c index 993a03a..429aa28 100644 --- a/backend_kodak6800.c +++ b/backend_kodak6800.c @@ -757,6 +757,8 @@ static int kodak6800_main_loop(void *vctx, int copies) { return CUPS_BACKEND_FAILED; /* Printer handles generating copies.. */ + if (copies > 255) // XXX test against remaining media? + copies = 255; if (ctx->hdr.copies < copies) ctx->hdr.copies = copies; diff --git a/backend_shinkos1245.c b/backend_shinkos1245.c index a21a8f7..4f47aca 100644 --- a/backend_shinkos1245.c +++ b/backend_shinkos1245.c @@ -1436,6 +1436,10 @@ static int shinkos1245_main_loop(void *vctx, int copies) { return CUPS_BACKEND_HOLD; } + /* Fix max print count. */ + if (copies > 9999) // XXX test against remaining media + copies = 9999; + top: if (state != last_state) { if (dyesub_debug) diff --git a/backend_shinkos2145.c b/backend_shinkos2145.c index 29dba69..8c3092b 100644 --- a/backend_shinkos2145.c +++ b/backend_shinkos2145.c @@ -1573,7 +1573,9 @@ static int shinkos2145_main_loop(void *vctx, int copies) { return CUPS_BACKEND_HOLD; } - top: + // XXX check copies against remaining media! + +top: if (state != last_state) { if (dyesub_debug) DEBUG("last_state %d new %d\n", last_state, state); diff --git a/backend_shinkos6145.c b/backend_shinkos6145.c index bdff832..dd84196 100644 --- a/backend_shinkos6145.c +++ b/backend_shinkos6145.c @@ -1762,6 +1762,8 @@ static int shinkos6145_main_loop(void *vctx, int copies) { return CUPS_BACKEND_HOLD; } + // XXX check copies against remaining media! + top: if (state != last_state) { if (dyesub_debug) diff --git a/backend_shinkos6245.c b/backend_shinkos6245.c index 45de0d6..13b63e9 100644 --- a/backend_shinkos6245.c +++ b/backend_shinkos6245.c @@ -1679,6 +1679,8 @@ static int shinkos6245_main_loop(void *vctx, int copies) { goto printer_error; } + // XXX check copies against remaining media! + top: if (state != last_state) { if (dyesub_debug)