void jpeg_data_load_file (JPEGData *data, const char *path) { FILE *f; unsigned char *d; unsigned int size; if ((data == NULL) || (path == NULL)) return; f = fopen (path, "rb"); if (f == NULL) return; /* For now, we read the data into memory. Patches welcome... */ fseek (f, 0, SEEK_END); size = ftell (f); fseek (f, 0, SEEK_SET); d = malloc (sizeof (char) * size); if (!d) { fclose (f); return; } if (fread (d, 1, size, f) != size) { free (d); fclose (f); return; } fclose (f); jpeg_data_load_data (data, d, size); free (d); }
JPEGData * jpeg_data_new_from_data (const unsigned char *d, unsigned int size) { JPEGData *data; data = jpeg_data_new (); jpeg_data_load_data (data, d, size); return (data); }
void jpeg_data_load_file (JPEGData *data, const char *path) { FILE *f; unsigned char *d; //For Fix Prevent Issue CID :13211 int size; if (!data) return; if (!path) return; f = fopen (path, "rb"); if (!f) { exif_log (data->priv->log, EXIF_LOG_CODE_CORRUPT_DATA, "jpeg-data", _("Path '%s' invalid."), path); return; } /* For now, we read the data into memory. Patches welcome... */ fseek (f, 0, SEEK_END); size = ftell (f); if(size <0){ fclose (f); return; } fseek (f, 0, SEEK_SET); d = malloc (size); if (!d) { EXIF_LOG_NO_MEMORY (data->priv->log, "jpeg-data", size); fclose (f); return; } if (fread (d, 1, size, f) != size) { free (d); fclose (f); exif_log (data->priv->log, EXIF_LOG_CODE_CORRUPT_DATA, "jpeg-data", _("Could not read '%s'."), path); return; } fclose (f); jpeg_data_load_data (data, d, size); free (d); }