]>
Commit | Line | Data |
---|---|---|
2abe5e57 JR |
1 | diff -up cups-1.7.0/scheduler/printers.c.stringpool-rdar15382819 cups-1.7.0/scheduler/printers.c |
2 | --- cups-1.7.0/scheduler/printers.c.stringpool-rdar15382819 2013-11-07 13:26:56.077499193 +0000 | |
3 | +++ cups-1.7.0/scheduler/printers.c 2013-11-07 13:27:54.665787144 +0000 | |
4 | @@ -1876,12 +1876,13 @@ void | |
5 | cupsdSetPrinterAttr( | |
6 | cupsd_printer_t *p, /* I - Printer */ | |
7 | const char *name, /* I - Attribute name */ | |
8 | - char *value) /* I - Attribute value string */ | |
9 | + const char *value) /* I - Attribute value string */ | |
10 | { | |
11 | ipp_attribute_t *attr; /* Attribute */ | |
12 | int i, /* Looping var */ | |
13 | count; /* Number of values */ | |
14 | - char *ptr, /* Pointer into value */ | |
15 | + char *temp, /* Temporary copy of value string */ | |
16 | + *ptr, /* Pointer into value */ | |
17 | *start, /* Start of value */ | |
18 | quote; /* Quote character */ | |
19 | ipp_tag_t value_tag; /* Value tag for this attribute */ | |
20 | @@ -1898,10 +1899,21 @@ cupsdSetPrinterAttr( | |
21 | } | |
22 | ||
23 | /* | |
24 | + * Copy the value string so we can do what we want with it... | |
25 | + */ | |
26 | + | |
27 | + if ((temp = strdup(value)) == NULL) | |
28 | + { | |
29 | + cupsdLogMessage(CUPSD_LOG_ERROR, | |
30 | + "Unable to duplicate value for \"%s\" attribute.", name); | |
31 | + return; | |
32 | + } | |
33 | + | |
34 | + /* | |
35 | * Count the number of values... | |
36 | */ | |
37 | ||
38 | - for (count = 1, quote = '\0', ptr = value; | |
39 | + for (count = 1, quote = '\0', ptr = temp; | |
40 | *ptr; | |
41 | ptr ++) | |
42 | { | |
43 | @@ -1949,15 +1961,15 @@ cupsdSetPrinterAttr( | |
44 | return; | |
45 | } | |
46 | ||
47 | - for (i = 0; i < count; i ++) | |
48 | + for (i = 0, start = temp; i < count; i ++) | |
49 | { | |
50 | - if ((ptr = strchr(value, ',')) != NULL) | |
51 | + if ((ptr = strchr(start, ',')) != NULL) | |
52 | *ptr++ = '\0'; | |
53 | ||
54 | - attr->values[i].integer = strtol(value, NULL, 10); | |
55 | + attr->values[i].integer = strtol(start, NULL, 10); | |
56 | ||
57 | if (ptr) | |
58 | - value = ptr; | |
59 | + start = ptr; | |
60 | } | |
61 | } | |
62 | else | |
63 | @@ -1999,7 +2011,7 @@ cupsdSetPrinterAttr( | |
64 | return; | |
65 | } | |
66 | ||
67 | - for (i = 0, quote = '\0', ptr = value; i < count; i ++) | |
68 | + for (i = 0, quote = '\0', ptr = temp; i < count; i ++) | |
69 | { | |
70 | for (start = ptr; *ptr; ptr ++) | |
71 | { | |
72 | @@ -2028,6 +2040,8 @@ cupsdSetPrinterAttr( | |
73 | attr->values[i].string.text = _cupsStrAlloc(start); | |
74 | } | |
75 | } | |
76 | + | |
77 | + free(temp); | |
78 | } | |
79 | ||
80 | ||
81 | diff -up cups-1.7.0/scheduler/printers.h.stringpool-rdar15382819 cups-1.7.0/scheduler/printers.h | |
82 | --- cups-1.7.0/scheduler/printers.h.stringpool-rdar15382819 2013-05-29 12:51:34.000000000 +0100 | |
83 | +++ cups-1.7.0/scheduler/printers.h 2013-11-07 13:27:54.666787149 +0000 | |
84 | @@ -166,7 +166,8 @@ extern int cupsdSetAuthInfoRequired(cup | |
85 | ipp_attribute_t *attr); | |
86 | extern void cupsdSetDeviceURI(cupsd_printer_t *p, const char *uri); | |
87 | extern void cupsdSetPrinterAttr(cupsd_printer_t *p, | |
88 | - const char *name, char *value); | |
89 | + const char *name, | |
90 | + const char *value); | |
91 | extern void cupsdSetPrinterAttrs(cupsd_printer_t *p); | |
92 | extern int cupsdSetPrinterReasons(cupsd_printer_t *p, | |
93 | const char *s); |