|
Line
Link Here
|
| 0 |
-- lib/Xm/XpmCrBufFrI.c |
0 |
++ lib/Xm/XpmCrBufFrI.c |
|
Lines 43-62
Link Here
|
| 43 |
|
43 |
|
| 44 |
#include "XpmI.h" |
44 |
#include "XpmI.h" |
| 45 |
|
45 |
|
| 46 |
LFUNC(WriteColors, int, (char **dataptr, unsigned int *data_size, |
46 |
LFUNC(WriteColors, int, (char **dataptr, size_t *data_size, |
| 47 |
unsigned int *used_size, XpmColor *colors, |
47 |
size_t *used_size, XpmColor *colors, |
| 48 |
unsigned int ncolors, unsigned int cpp)); |
48 |
unsigned int ncolors, unsigned int cpp)); |
| 49 |
|
49 |
|
| 50 |
LFUNC(WritePixels, void, (char *dataptr, unsigned int *used_size, |
50 |
LFUNC(WritePixels, void, (char *dataptr, size_t *used_size, |
| 51 |
unsigned int width, unsigned int height, |
51 |
unsigned int width, unsigned int height, |
| 52 |
unsigned int cpp, unsigned int *pixels, |
52 |
unsigned int cpp, unsigned int *pixels, |
| 53 |
XpmColor *colors)); |
53 |
XpmColor *colors)); |
| 54 |
|
54 |
|
| 55 |
LFUNC(WriteExtensions, void, (char *dataptr, unsigned int *used_size, |
55 |
LFUNC(WriteExtensions, void, (char *dataptr, size_t *used_size, |
| 56 |
XpmExtension *ext, unsigned int num)); |
56 |
XpmExtension *ext, unsigned int num)); |
| 57 |
|
57 |
|
| 58 |
LFUNC(ExtensionsSize, int, (XpmExtension *ext, unsigned int num)); |
58 |
LFUNC(ExtensionsSize, size_t, (XpmExtension *ext, unsigned int num)); |
| 59 |
LFUNC(CommentsSize, int, (XpmInfo *info)); |
59 |
LFUNC(CommentsSize, size_t, (XpmInfo *info)); |
| 60 |
|
60 |
|
| 61 |
int |
61 |
int |
| 62 |
XpmCreateBufferFromImage(display, buffer_return, image, shapeimage, attributes) |
62 |
XpmCreateBufferFromImage(display, buffer_return, image, shapeimage, attributes) |
|
Lines 113-122
Link Here
|
| 113 |
/* calculation variables */ |
113 |
/* calculation variables */ |
| 114 |
int ErrorStatus; |
114 |
int ErrorStatus; |
| 115 |
char buf[BUFSIZ]; |
115 |
char buf[BUFSIZ]; |
| 116 |
unsigned int cmts, extensions, ext_size = 0; |
116 |
unsigned int cmts, extensions; |
| 117 |
unsigned int l, cmt_size = 0; |
117 |
size_t ext_size = 0; |
|
|
118 |
size_t l, cmt_size = 0; |
| 118 |
char *ptr = NULL, *p; |
119 |
char *ptr = NULL, *p; |
| 119 |
unsigned int ptr_size, used_size; |
120 |
size_t ptr_size, used_size; |
| 120 |
|
121 |
|
| 121 |
*buffer_return = NULL; |
122 |
*buffer_return = NULL; |
| 122 |
|
123 |
|
|
Lines 253-260
Link Here
|
| 253 |
static int |
254 |
static int |
| 254 |
WriteColors(dataptr, data_size, used_size, colors, ncolors, cpp) |
255 |
WriteColors(dataptr, data_size, used_size, colors, ncolors, cpp) |
| 255 |
char **dataptr; |
256 |
char **dataptr; |
| 256 |
unsigned int *data_size; |
257 |
size_t *data_size; |
| 257 |
unsigned int *used_size; |
258 |
size_t *used_size; |
| 258 |
XpmColor *colors; |
259 |
XpmColor *colors; |
| 259 |
unsigned int ncolors; |
260 |
unsigned int ncolors; |
| 260 |
unsigned int cpp; |
261 |
unsigned int cpp; |
|
Lines 299-305
Link Here
|
| 299 |
static void |
300 |
static void |
| 300 |
WritePixels(dataptr, used_size, width, height, cpp, pixels, colors) |
301 |
WritePixels(dataptr, used_size, width, height, cpp, pixels, colors) |
| 301 |
char *dataptr; |
302 |
char *dataptr; |
| 302 |
unsigned int *used_size; |
303 |
size_t *used_size; |
| 303 |
unsigned int width; |
304 |
unsigned int width; |
| 304 |
unsigned int height; |
305 |
unsigned int height; |
| 305 |
unsigned int cpp; |
306 |
unsigned int cpp; |
|
Lines 329-340
Link Here
|
| 329 |
*used_size += s - dataptr; |
330 |
*used_size += s - dataptr; |
| 330 |
} |
331 |
} |
| 331 |
|
332 |
|
| 332 |
static int |
333 |
static size_t |
| 333 |
ExtensionsSize(ext, num) |
334 |
ExtensionsSize(ext, num) |
| 334 |
XpmExtension *ext; |
335 |
XpmExtension *ext; |
| 335 |
unsigned int num; |
336 |
unsigned int num; |
| 336 |
{ |
337 |
{ |
| 337 |
unsigned int x, y, a, size; |
338 |
unsigned int x, y, a; |
|
|
339 |
size_t size; |
| 338 |
char **line; |
340 |
char **line; |
| 339 |
|
341 |
|
| 340 |
size = 0; |
342 |
size = 0; |
|
Lines 353-359
Link Here
|
| 353 |
static void |
355 |
static void |
| 354 |
WriteExtensions(dataptr, used_size, ext, num) |
356 |
WriteExtensions(dataptr, used_size, ext, num) |
| 355 |
char *dataptr; |
357 |
char *dataptr; |
| 356 |
unsigned int *used_size; |
358 |
size_t *used_size; |
| 357 |
XpmExtension *ext; |
359 |
XpmExtension *ext; |
| 358 |
unsigned int num; |
360 |
unsigned int num; |
| 359 |
{ |
361 |
{ |
|
Lines 384-394
Link Here
|
| 384 |
*used_size += s - dataptr + 13; |
386 |
*used_size += s - dataptr + 13; |
| 385 |
} |
387 |
} |
| 386 |
|
388 |
|
| 387 |
static int |
389 |
static size_t |
| 388 |
CommentsSize(info) |
390 |
CommentsSize(info) |
| 389 |
XpmInfo *info; |
391 |
XpmInfo *info; |
| 390 |
{ |
392 |
{ |
| 391 |
int size = 0; |
393 |
size_t size = 0; |
| 392 |
|
394 |
|
| 393 |
/* 5 = 2 (for "/_*") + 3 (for "*_/\n") */ |
395 |
/* 5 = 2 (for "/_*") + 3 (for "*_/\n") */ |
| 394 |
if (info->hints_cmt) |
396 |
if (info->hints_cmt) |
| 395 |
-- lib/Xm/XpmI.h |
397 |
++ lib/Xm/XpmI.h |
|
Lines 184-192
Link Here
|
| 184 |
unsigned int type; |
184 |
unsigned int type; |
| 185 |
union { |
185 |
union { |
| 186 |
FILE *file; |
186 |
FILE *file; |
| 187 |
char **data; |
187 |
unsigned char **data; |
| 188 |
} stream; |
188 |
} stream; |
| 189 |
char *cptr; |
189 |
unsigned char *cptr; |
| 190 |
unsigned int line; |
190 |
unsigned int line; |
| 191 |
int CommentLength; |
191 |
int CommentLength; |
| 192 |
char Comment[XPMMAXCMTLEN]; |
192 |
char Comment[XPMMAXCMTLEN]; |
| 193 |
-- lib/Xm/XpmRdFToI.c |
193 |
++ lib/Xm/XpmRdFToI.c |
|
Lines 124-129
Link Here
|
| 124 |
return (ErrorStatus); |
124 |
return (ErrorStatus); |
| 125 |
} |
125 |
} |
| 126 |
|
126 |
|
|
|
127 |
|
| 128 |
/* Quote filename and prepend prefix. */ |
| 129 |
static char *quote_file(prefix, filename, len) |
| 130 |
const char *prefix, *filename; |
| 131 |
size_t len; |
| 132 |
{ |
| 133 |
char *buf = XpmMalloc(strlen(prefix) + len * 2 + 1); |
| 134 |
char *p = buf, *q; |
| 135 |
|
| 136 |
if (!buf) |
| 137 |
return 0; |
| 138 |
strcpy(p, prefix); |
| 139 |
p += strlen(p); |
| 140 |
for (q = filename; *q; q++) { |
| 141 |
*p++ = '\\'; |
| 142 |
*p++ = *q; |
| 143 |
} |
| 144 |
return buf; |
| 145 |
} |
| 146 |
|
| 147 |
|
| 127 |
/* |
148 |
/* |
| 128 |
* open the given file to be read as an xpmData which is returned. |
149 |
* open the given file to be read as an xpmData which is returned. |
| 129 |
*/ |
150 |
*/ |
|
Lines 133-139
Link Here
|
| 133 |
xpmData *mdata; |
154 |
xpmData *mdata; |
| 134 |
{ |
155 |
{ |
| 135 |
#ifndef NO_ZPIPE |
156 |
#ifndef NO_ZPIPE |
| 136 |
char *compressfile, buf[(2*MAXPATHLEN) + 1]; |
157 |
char *compressfile, *buf; |
| 137 |
# ifdef STAT_ZFILE |
158 |
# ifdef STAT_ZFILE |
| 138 |
struct stat status; |
159 |
struct stat status; |
| 139 |
# endif |
160 |
# endif |
|
Lines 144-160
Link Here
|
| 144 |
mdata->type = XPMFILE; |
165 |
mdata->type = XPMFILE; |
| 145 |
} else { |
166 |
} else { |
| 146 |
#ifndef NO_ZPIPE |
167 |
#ifndef NO_ZPIPE |
| 147 |
int len = strlen(filename); |
168 |
size_t len = strlen(filename); |
| 148 |
if ((len > 2) && !strcmp(".Z", filename + (len - 2))) { |
169 |
if ((len > 2) && !strcmp(".Z", filename + (len - 2))) { |
| 149 |
mdata->type = XPMPIPE; |
170 |
mdata->type = XPMPIPE; |
| 150 |
sprintf(buf, "uncompress -c \"%s\"", filename); |
171 |
buf = quote_file("uncompress -c ", filename, len); |
| 151 |
if (!(mdata->stream.file = popen(buf, "r"))) |
172 |
if (!buf) |
|
|
173 |
return (XpmNoMemory); |
| 174 |
mdata->stream.file = popen(buf, "r"); |
| 175 |
XpmFree(buf); |
| 176 |
if (!mdata->stream.file) |
| 152 |
return (XpmOpenFailed); |
177 |
return (XpmOpenFailed); |
| 153 |
|
178 |
|
| 154 |
} else if ((len > 3) && !strcmp(".gz", filename + (len - 3))) { |
179 |
} else if ((len > 3) && !strcmp(".gz", filename + (len - 3))) { |
| 155 |
mdata->type = XPMPIPE; |
180 |
mdata->type = XPMPIPE; |
| 156 |
sprintf(buf, "gunzip -qc \"%s\"", filename); |
181 |
buf = quote_file("gunzip -qc ", filename, len); |
| 157 |
if (!(mdata->stream.file = popen(buf, "r"))) |
182 |
if (!buf) |
|
|
183 |
return (XpmNoMemory); |
| 184 |
mdata->stream.file = popen(buf, "r"); |
| 185 |
XpmFree(buf); |
| 186 |
if (!mdata->stream.file) |
| 158 |
return (XpmOpenFailed); |
187 |
return (XpmOpenFailed); |
| 159 |
|
188 |
|
| 160 |
} else { |
189 |
} else { |
|
Lines 164-191
Link Here
|
| 164 |
|
193 |
|
| 165 |
sprintf(compressfile, "%s.Z", filename); |
194 |
sprintf(compressfile, "%s.Z", filename); |
| 166 |
if (!stat(compressfile, &status)) { |
195 |
if (!stat(compressfile, &status)) { |
| 167 |
sprintf(buf, "uncompress -c \"%s\"", compressfile); |
196 |
buf = quote_file("uncompress -c ", compressfile, len + 2); |
| 168 |
if (!(mdata->stream.file = popen(buf, "r"))) { |
197 |
XpmFree(compressfile); |
| 169 |
XpmFree(compressfile); |
198 |
if (!buf) |
|
|
199 |
return (XpmNoMemory); |
| 200 |
mdata->stream.file = popen(buf, "r"); |
| 201 |
XpmFree(buf); |
| 202 |
if (!mdata->stream.file) |
| 170 |
return (XpmOpenFailed); |
203 |
return (XpmOpenFailed); |
| 171 |
} |
|
|
| 172 |
mdata->type = XPMPIPE; |
204 |
mdata->type = XPMPIPE; |
| 173 |
} else { |
205 |
} else { |
| 174 |
sprintf(compressfile, "%s.gz", filename); |
206 |
sprintf(compressfile, "%s.gz", filename); |
| 175 |
if (!stat(compressfile, &status)) { |
207 |
if (!stat(compressfile, &status)) { |
| 176 |
sprintf(buf, "gunzip -c \"%s\"", compressfile); |
208 |
buf = quote_file("gunzip -c ", compressfile, len + 3); |
| 177 |
if (!(mdata->stream.file = popen(buf, "r"))) { |
209 |
XpmFree(compressfile); |
| 178 |
XpmFree(compressfile); |
210 |
if (!buf) |
|
|
211 |
return (XpmNoMemory); |
| 212 |
mdata->stream.file = popen(buf, "r"); |
| 213 |
XpmFree(buf); |
| 214 |
if (!mdata->stream.file) |
| 179 |
return (XpmOpenFailed); |
215 |
return (XpmOpenFailed); |
| 180 |
} |
|
|
| 181 |
mdata->type = XPMPIPE; |
216 |
mdata->type = XPMPIPE; |
| 182 |
} else { |
217 |
} else { |
|
|
218 |
XpmFree(compressfile); |
| 183 |
# endif |
219 |
# endif |
| 184 |
#endif |
220 |
#endif |
| 185 |
if (!(mdata->stream.file = fopen(filename, "r"))) { |
221 |
if (!(mdata->stream.file = fopen(filename, "r"))) { |
| 186 |
#if !defined(NO_ZPIPE) && defined(STAT_ZFILE) |
|
|
| 187 |
XpmFree(compressfile); |
| 188 |
#endif |
| 189 |
return (XpmOpenFailed); |
222 |
return (XpmOpenFailed); |
| 190 |
} |
223 |
} |
| 191 |
mdata->type = XPMFILE; |
224 |
mdata->type = XPMFILE; |
|
Lines 193-199
Link Here
|
| 193 |
# ifdef STAT_ZFILE |
226 |
# ifdef STAT_ZFILE |
| 194 |
} |
227 |
} |
| 195 |
} |
228 |
} |
| 196 |
XpmFree(compressfile); |
|
|
| 197 |
# endif |
229 |
# endif |
| 198 |
} |
230 |
} |
| 199 |
#endif |
231 |
#endif |
| 200 |
-- lib/Xm/Xpmdata.c |
232 |
++ lib/Xm/Xpmdata.c |
|
Lines 297-303
Link Here
|
| 297 |
|
297 |
|
| 298 |
if (!mdata->type || mdata->type == XPMBUFFER) { |
298 |
if (!mdata->type || mdata->type == XPMBUFFER) { |
| 299 |
if (mdata->cptr) { |
299 |
if (mdata->cptr) { |
| 300 |
char *start = mdata->cptr; |
300 |
unsigned char *start = mdata->cptr; |
| 301 |
while ((c = *mdata->cptr) && c != mdata->Eos) |
301 |
while ((c = *mdata->cptr) && c != mdata->Eos) |
| 302 |
mdata->cptr++; |
302 |
mdata->cptr++; |
| 303 |
n = mdata->cptr - start + 1; |
303 |
n = mdata->cptr - start + 1; |
| 304 |
-- lib/Xm/Xpmhashtab.c |
304 |
++ lib/Xm/Xpmhashtab.c |
|
Lines 148-154
Link Here
|
| 148 |
|
148 |
|
| 149 |
t = atomTable; |
149 |
t = atomTable; |
| 150 |
HASH_TABLE_GROWS |
150 |
HASH_TABLE_GROWS |
| 151 |
table->size = size; |
151 |
if (size <= 0) |
|
|
152 |
return (XpmNoMemory); |
| 153 |
table->size = size; |
| 152 |
table->limit = size / 3; |
154 |
table->limit = size / 3; |
| 153 |
atomTable = (xpmHashAtom *) XpmMalloc(size * sizeof(*atomTable)); |
155 |
atomTable = (xpmHashAtom *) XpmMalloc(size * sizeof(*atomTable)); |
| 154 |
if (!atomTable) |
156 |
if (!atomTable) |
| 155 |
-- lib/Xm/Xpmmisc.c |
157 |
++ lib/Xm/Xpmmisc.c |
|
Lines 52-58
Link Here
|
| 52 |
char *s1; |
52 |
char *s1; |
| 53 |
{ |
53 |
{ |
| 54 |
char *s2; |
54 |
char *s2; |
| 55 |
int l = strlen(s1) + 1; |
55 |
size_t l = strlen(s1) + 1; |
| 56 |
|
56 |
|
| 57 |
if (s2 = (char *) XpmMalloc(l)) |
57 |
if (s2 = (char *) XpmMalloc(l)) |
| 58 |
strcpy(s2, s1); |
58 |
strcpy(s2, s1); |
| 59 |
-- lib/Xm/Xpmparse.c |
59 |
++ lib/Xm/Xpmparse.c |
|
Lines 313-318
Link Here
|
| 313 |
*hotspot = 0; |
313 |
*hotspot = 0; |
| 314 |
*extensions = 0; |
314 |
*extensions = 0; |
| 315 |
} |
315 |
} |
|
|
316 |
|
| 317 |
/* Do some plausibility checks. */ |
| 318 |
if (*width == 0 || *height == 0 || *ncolors == 0 || *cpp == 0) |
| 319 |
return XpmFileInvalid; |
| 320 |
if (*cpp > 8) |
| 321 |
return XpmFileInvalid; |
| 322 |
if (*width > (1 << (sizeof(int) - 4)) / *height) |
| 323 |
return XpmFileInvalid; |
| 324 |
if (*ncolors > (1 << (sizeof(int) - 4)) / (*width * *height)) |
| 325 |
return XpmFileInvalid; |
| 326 |
|
| 316 |
return (XpmSuccess); |
327 |
return (XpmSuccess); |
| 317 |
} |
328 |
} |
| 318 |
|
329 |
|
|
Lines 399-404
Link Here
|
| 399 |
xpmFreeColorTable(colorTable, ncolors); |
410 |
xpmFreeColorTable(colorTable, ncolors); |
| 400 |
return (XpmFileInvalid); |
411 |
return (XpmFileInvalid); |
| 401 |
} |
412 |
} |
|
|
413 |
if (strlen(curbuf) + l + 2 >= sizeof(curbuf)) { |
| 414 |
xpmFreeColorTable(colorTable, ncolors); |
| 415 |
return (XpmNoMemory); |
| 416 |
} |
| 402 |
if (!lastwaskey) |
417 |
if (!lastwaskey) |
| 403 |
strcat(curbuf, " "); /* append space */ |
418 |
strcat(curbuf, " "); /* append space */ |
| 404 |
buf[l] = '\0'; |
419 |
buf[l] = '\0'; |
|
Lines 455-460
Link Here
|
| 455 |
xpmNextString(data); /* get to the next string */ |
470 |
xpmNextString(data); /* get to the next string */ |
| 456 |
*curbuf = '\0'; /* init curbuf */ |
471 |
*curbuf = '\0'; /* init curbuf */ |
| 457 |
while ((l = xpmNextWord(data, buf, BUFSIZ))) { |
472 |
while ((l = xpmNextWord(data, buf, BUFSIZ))) { |
|
|
473 |
if (strlen(curbuf) + l + 2 >= sizeof(curbuf)) { |
| 474 |
xpmFreeColorTable(colorTable, ncolors); |
| 475 |
return (XpmNoMemory); |
| 476 |
} |
| 458 |
if (*curbuf != '\0') |
477 |
if (*curbuf != '\0') |
| 459 |
strcat(curbuf, " ");/* append space */ |
478 |
strcat(curbuf, " ");/* append space */ |
| 460 |
buf[l] = '\0'; |
479 |
buf[l] = '\0'; |
|
Lines 547-553
Link Here
|
| 547 |
|
566 |
|
| 548 |
bzero((char *)cidx, 256 * sizeof(unsigned short *)); /* init */ |
567 |
bzero((char *)cidx, 256 * sizeof(unsigned short *)); /* init */ |
| 549 |
for (a = 0; a < ncolors; a++) { |
568 |
for (a = 0; a < ncolors; a++) { |
| 550 |
char1 = colorTable[a].string[0]; |
569 |
char1 = (unsigned char)colorTable[a].string[0]; |
| 551 |
if (cidx[char1] == NULL) { /* get new memory */ |
570 |
if (cidx[char1] == NULL) { /* get new memory */ |
| 552 |
cidx[char1] = (unsigned short *) |
571 |
cidx[char1] = (unsigned short *) |
| 553 |
XpmCalloc(256, sizeof(unsigned short)); |
572 |
XpmCalloc(256, sizeof(unsigned short)); |