summaryrefslogtreecommitdiffstats
path: root/backend_mitsud90.c
diff options
context:
space:
mode:
authorSolomon Peachy <pizza@shaftnet.org>2020-03-05 23:36:51 -0500
committerSolomon Peachy <pizza@shaftnet.org>2020-03-05 23:36:51 -0500
commit41b4d16bcdbca1eacd33d6b3d6d33d77b0171c96 (patch)
tree1490d181ef483906bb99dc716378234c6e275013 /backend_mitsud90.c
parentad45c85efc4ebcea941e00fe9109179f24cd245c (diff)
downloadselphy_print-41b4d16bcdbca1eacd33d6b3d6d33d77b0171c96.tar.gz
selphy_print-41b4d16bcdbca1eacd33d6b3d6d33d77b0171c96.tar.bz2
selphy_print-41b4d16bcdbca1eacd33d6b3d6d33d77b0171c96.zip
mitsud90: Sanity check margin cut parameters.
Diffstat (limited to 'backend_mitsud90.c')
-rw-r--r--backend_mitsud90.c30
1 files changed, 28 insertions, 2 deletions
diff --git a/backend_mitsud90.c b/backend_mitsud90.c
index c18df4c..1837ac4 100644
--- a/backend_mitsud90.c
+++ b/backend_mitsud90.c
@@ -178,7 +178,7 @@ struct mitsud90_job_hdr {
uint8_t waittime; /* 0-100 */
uint8_t unk[3]; /* 00 00 01 */ // XXX 00 01 might be the jobid?
uint8_t margincut; /* 1 for enabled, 0 for disabled */
- uint8_t cuttype; /* # of cuts (0-3) but 0-8 legal */
+ uint8_t numcuts; /* # of cuts (0-3) but 0-8 legal */
/*@0x10*/
struct {
uint16_t position; // @ center?
@@ -752,6 +752,32 @@ static int mitsud90_read_parse(void *vctx, const void **vjob, int data_fd, int c
return CUPS_BACKEND_CANCEL;
}
+ /* Sanity check cutlist */
+ if (job->hdr.numcuts > 3) {
+ ERROR("Cut list too long!\n");
+ mitsud90_cleanup_job(job);
+ return CUPS_BACKEND_CANCEL;
+ }
+ if (job->hdr.numcuts >= 1) {
+ if (be16_to_cpu(job->hdr.cutlist[0].position) < 613) {
+ ERROR("Minumum cut1 length is 613 rows\n");
+ mitsud90_cleanup_job(job);
+ return CUPS_BACKEND_CANCEL;
+ }
+ for (i = 1 ; i < job->hdr.numcuts ; i++) {
+ int min_size;
+ if (job->hdr.cutlist[i-1].margincut)
+ min_size = 606; // XXX inverted?
+ else
+ min_size = 660;
+ if (be16_to_cpu(job->hdr.cutlist[i].position) - be16_to_cpu(job->hdr.cutlist[i-1].position) < min_size) {
+ ERROR("Minumum cutN length is %d rows!\n", min_size);
+ mitsud90_cleanup_job(job);
+ return CUPS_BACKEND_CANCEL;
+ }
+ }
+ }
+
/* How many pixels do we need to read? */
remain = be16_to_cpu(job->hdr.cols) * be16_to_cpu(job->hdr.rows) * 3;
@@ -1667,7 +1693,7 @@ static const char *mitsud90_prefixes[] = {
/* Exported */
struct dyesub_backend mitsud90_backend = {
.name = "Mitsubishi CP-D90/CP-M1",
- .version = "0.27" " (lib " LIBMITSU_VER ")",
+ .version = "0.28" " (lib " LIBMITSU_VER ")",
.uri_prefixes = mitsud90_prefixes,
.cmdline_arg = mitsud90_cmdline_arg,
.cmdline_usage = mitsud90_cmdline,