summaryrefslogtreecommitdiff
path: root/debian/patches/0001-Upstream-patch-to-fix-the-gutenprint52-usb-CUPS-back.patch
blob: ce3d500904aa3fbc88cdd475cd513b690de5b28f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
From c3cdc5f0fadf136e5df3d2873517f4f51a949691 Mon Sep 17 00:00:00 2001
From: Till Kamppeter <till.kamppeter@gmail.com>
Date: Tue, 18 Mar 2014 23:13:37 +0100
Subject: [PATCH 1/2] Upstream patch to fix the gutenprint52+usb CUPS backend
 crashing on failure of USB access via libusb

LP: #1297326
---
 src/cups/backend_common.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/src/cups/backend_common.c b/src/cups/backend_common.c
index 1139e12..bcf1e8b 100644
--- a/src/cups/backend_common.c
+++ b/src/cups/backend_common.c
@@ -473,6 +473,7 @@ static void print_help(char *argv0, struct dyesub_backend *backend)
 {
 	struct libusb_context *ctx = NULL;
 	struct libusb_device **list = NULL;
+	int i;
 
 	char *ptr = strrchr(argv0, '/');
 	if (ptr)
@@ -513,7 +514,12 @@ static void print_help(char *argv0, struct dyesub_backend *backend)
 		if (backend->cmdline_usage)
 			backend->cmdline_usage();
 	}
-	libusb_init(&ctx);
+
+	i = libusb_init(&ctx);
+	if (i) {
+		ERROR("Failed to initialize libusb (%d)\n", i);
+		exit(4); /* CUPS_BACKEND_STOP */
+	}
 	find_and_enumerate(ctx, &list, backend, NULL, P_ANY, 1);
 	libusb_free_device_list(list, 1);
 	libusb_exit(ctx);
@@ -746,7 +752,13 @@ int main (int argc, char **argv)
 	}
 
 	/* Libusb setup */
-	libusb_init(&ctx);
+	ret = libusb_init(&ctx);
+	if (ret) {
+		ERROR("Failed to initialize libusb (%d)\n", ret);
+		ret = 4;
+		goto done;
+	}
+
 	/* Enumerate devices */
 	found = find_and_enumerate(ctx, &list, backend, use_serno, printer_type, 0);