summaryrefslogtreecommitdiffstats
path: root/backend_dnpds40.c
diff options
context:
space:
mode:
authorSolomon Peachy <pizza@shaftnet.org>2020-03-17 22:00:52 -0400
committerSolomon Peachy <pizza@shaftnet.org>2020-03-17 22:04:17 -0400
commitb565076492308547027ba8419c964593149affb4 (patch)
tree75f73d069b1044ef7c05d0b973410b34b7adb7d1 /backend_dnpds40.c
parent4652175546feacbb7c9db3a564dbf29e777d04ff (diff)
downloadselphy_print-b565076492308547027ba8419c964593149affb4.tar.gz
selphy_print-b565076492308547027ba8419c964593149affb4.tar.bz2
selphy_print-b565076492308547027ba8419c964593149affb4.zip
dnp: Fix segfault. Bad Solomon.
Diffstat (limited to 'backend_dnpds40.c')
-rw-r--r--backend_dnpds40.c47
1 files changed, 27 insertions, 20 deletions
diff --git a/backend_dnpds40.c b/backend_dnpds40.c
index 62e3575..5fb6e37 100644
--- a/backend_dnpds40.c
+++ b/backend_dnpds40.c
@@ -809,6 +809,33 @@ static int dnpds40_attach(void *vctx, struct libusb_device_handle *dev, int type
/* All current models support 600dpi */
ctx->supports_600dpi = 1;
+ if (test_mode < TEST_MODE_NOATTACH) {
+ struct dnpds40_cmd cmd;
+ uint8_t *resp;
+ int len = 0;
+
+ /* Get Firmware Version */
+ dnpds40_build_cmd(&cmd, "INFO", "FVER", 0);
+
+ resp = dnpds40_resp_cmd(ctx, &cmd, &len);
+ if (resp) {
+ char *ptr;
+ dnpds40_cleanup_string((char*)resp, len);
+ ctx->version = strdup((char*) resp);
+
+ /* Parse version */
+ /* ptr = */ strtok((char*)resp, " .");
+ ptr = strtok(NULL, ".");
+ ctx->ver_major = atoi(ptr);
+ ptr = strtok(NULL, ".");
+ ctx->ver_minor = atoi(ptr);
+
+ free(resp);
+ } else {
+ return CUPS_BACKEND_FAILED;
+ }
+ }
+
/* Per-printer options */
switch (ctx->type) {
case P_DNP_DS40:
@@ -937,26 +964,6 @@ static int dnpds40_attach(void *vctx, struct libusb_device_handle *dev, int type
uint8_t *resp;
int len = 0;
- /* Get Firmware Version */
- dnpds40_build_cmd(&cmd, "INFO", "FVER", 0);
-
- resp = dnpds40_resp_cmd(ctx, &cmd, &len);
- if (resp) {
- char *ptr;
- dnpds40_cleanup_string((char*)resp, len);
- ctx->version = strdup((char*) resp);
-
- /* Parse version */
- /* ptr = */ strtok((char*)resp, " .");
- ptr = strtok(NULL, ".");
- ctx->ver_major = atoi(ptr);
- ptr = strtok(NULL, ".");
- ctx->ver_minor = atoi(ptr);
- free(resp);
- } else {
- return CUPS_BACKEND_FAILED;
- }
-
/* Get Serial Number */
dnpds40_build_cmd(&cmd, "INFO", "SERIAL_NUMBER", 0);