Lines 313-324
Link Here
|
313 |
* -1 if access denied or not found, 0 if ok. |
313 |
* -1 if access denied or not found, 0 if ok. |
314 |
*/ |
314 |
*/ |
315 |
|
315 |
|
316 |
int findImage(name, fullname) |
316 |
int findImage(name, fullname, size) |
317 |
char *name, *fullname; |
317 |
char *name, *fullname; |
|
|
318 |
size_t size; |
318 |
{ unsigned int p, e; |
319 |
{ unsigned int p, e; |
319 |
struct stat sbuf; |
320 |
struct stat sbuf; |
320 |
|
321 |
|
321 |
strcpy(fullname, name); |
322 |
strncpy(fullname, name, size); |
322 |
if (!strcmp(name, "stdin")) /* stdin is special name */ |
323 |
if (!strcmp(name, "stdin")) /* stdin is special name */ |
323 |
return(0); |
324 |
return(0); |
324 |
|
325 |
|
Lines 327-333
Link Here
|
327 |
if (! stat(fullname, &sbuf)) |
328 |
if (! stat(fullname, &sbuf)) |
328 |
return(fileIsOk(fullname, &sbuf)); |
329 |
return(fileIsOk(fullname, &sbuf)); |
329 |
#ifndef NO_COMPRESS |
330 |
#ifndef NO_COMPRESS |
330 |
strcat(fullname, ".Z"); |
331 |
strncat(fullname, ".Z", size); |
331 |
if (! stat(fullname, &sbuf)) |
332 |
if (! stat(fullname, &sbuf)) |
332 |
return(fileIsOk(fullname, &sbuf)); |
333 |
return(fileIsOk(fullname, &sbuf)); |
333 |
#endif |
334 |
#endif |
Lines 336-347
Link Here
|
336 |
#ifdef VMS |
337 |
#ifdef VMS |
337 |
sprintf(fullname, "%s%s", Paths[p], name); |
338 |
sprintf(fullname, "%s%s", Paths[p], name); |
338 |
#else |
339 |
#else |
339 |
sprintf(fullname, "%s/%s", Paths[p], name); |
340 |
snprintf(fullname, size, "%s/%s", Paths[p], name); |
340 |
#endif |
341 |
#endif |
341 |
if (! stat(fullname, &sbuf)) |
342 |
if (! stat(fullname, &sbuf)) |
342 |
return(fileIsOk(fullname, &sbuf)); |
343 |
return(fileIsOk(fullname, &sbuf)); |
343 |
#ifndef NO_COMPRESS |
344 |
#ifndef NO_COMPRESS |
344 |
strcat(fullname, ".Z"); |
345 |
strncat(fullname, ".Z", size); |
345 |
if (! stat(fullname, &sbuf)) |
346 |
if (! stat(fullname, &sbuf)) |
346 |
#endif |
347 |
#endif |
347 |
return(fileIsOk(fullname, &sbuf)); |
348 |
return(fileIsOk(fullname, &sbuf)); |
Lines 349-360
Link Here
|
349 |
#ifdef VMS |
350 |
#ifdef VMS |
350 |
sprintf(fullname, "%s%s%s", Paths[p], name, Exts[e]); |
351 |
sprintf(fullname, "%s%s%s", Paths[p], name, Exts[e]); |
351 |
#else |
352 |
#else |
352 |
sprintf(fullname, "%s/%s%s", Paths[p], name, Exts[e]); |
353 |
snprintf(fullname, size, "%s/%s%s", Paths[p], name, Exts[e]); |
353 |
#endif |
354 |
#endif |
354 |
if (! stat(fullname, &sbuf)) |
355 |
if (! stat(fullname, &sbuf)) |
355 |
return(fileIsOk(fullname, &sbuf)); |
356 |
return(fileIsOk(fullname, &sbuf)); |
356 |
#ifndef NO_COMPRESS |
357 |
#ifndef NO_COMPRESS |
357 |
strcat(fullname, ".Z"); |
358 |
strncat(fullname, ".Z", size); |
358 |
if (! stat(fullname, &sbuf)) |
359 |
if (! stat(fullname, &sbuf)) |
359 |
return(fileIsOk(fullname, &sbuf)); |
360 |
return(fileIsOk(fullname, &sbuf)); |
360 |
#endif |
361 |
#endif |
Lines 362-372
Link Here
|
362 |
} |
363 |
} |
363 |
|
364 |
|
364 |
for (e= 0; e < NumExts; e++) { |
365 |
for (e= 0; e < NumExts; e++) { |
365 |
sprintf(fullname, "%s%s", name, Exts[e]); |
366 |
snprintf(fullname, size, "%s%s", name, Exts[e]); |
366 |
if (! stat(fullname, &sbuf)) |
367 |
if (! stat(fullname, &sbuf)) |
367 |
return(fileIsOk(fullname, &sbuf)); |
368 |
return(fileIsOk(fullname, &sbuf)); |
368 |
#ifndef NO_COMPRESS |
369 |
#ifndef NO_COMPRESS |
369 |
strcat(fullname, ".Z"); |
370 |
strncat(fullname, ".Z", size); |
370 |
if (! stat(fullname, &sbuf)) |
371 |
if (! stat(fullname, &sbuf)) |
371 |
return(fileIsOk(fullname, &sbuf)); |
372 |
return(fileIsOk(fullname, &sbuf)); |
372 |
#endif |
373 |
#endif |
Lines 392-398
Link Here
|
392 |
#ifdef VMS |
393 |
#ifdef VMS |
393 |
sprintf(buf, "directory %s", Paths[a]); |
394 |
sprintf(buf, "directory %s", Paths[a]); |
394 |
#else |
395 |
#else |
395 |
sprintf(buf, "ls %s", Paths[a]); |
396 |
snprintf(buf, sizeof(buf)-1, "ls %s", Paths[a]); |
396 |
#endif |
397 |
#endif |
397 |
if (system(buf) < 0) { |
398 |
if (system(buf) < 0) { |
398 |
#ifdef VMS |
399 |
#ifdef VMS |