Skip to content
This repository has been archived by the owner on Feb 15, 2022. It is now read-only.

Commit

Permalink
Don't cache results from last file examined
Browse files Browse the repository at this point in the history
- The filename was stored in a fixed-size buffer, which seems to be a rich
  source of security vulnerabilities

- The cache would incorrectly report no change when using a single temporary
  filename, with contents that vary over time

- It's of value only in very restricted situations: the only code that could
  take advantage of the cache is something that's repeatedly loading the
  same file, without loading any other files in between

Given the latter point, it doesn't seem worth fixing the first two issues.
  • Loading branch information
arc committed May 6, 2012
1 parent 4bb3976 commit 5e9967f
Showing 1 changed file with 1 addition and 11 deletions.
12 changes: 1 addition & 11 deletions Image-EXIF.xs
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,16 @@ unsigned short dumplvl = 0;
static int
read_data(char *name)
{
static char prev_name[1024] = "";

int mark, first = 0;
unsigned int len, rlen;
unsigned char *exifbuf = NULL;
FILE *fp = fopen(name, "rb");

FILE *fp;

if (strcmp(name, prev_name) == 0)
return 0;

fp = fopen(name, "rb");
if (!fp) {
prev_name[0] = '\0';
exifdie((const char *)strerror(errno));
return 2;
}

strcpy(prev_name, name);

while (jpegscan(fp, &mark, &len, !(first++))) {
if (mark != JPEG_M_APP1) {
if (fseek(fp, len, SEEK_CUR)) {
Expand Down

0 comments on commit 5e9967f

Please sign in to comment.