#include <libexif/exif-utils.h>
#include <libexif/exif-loader.h>
#include <libexif/exif-log.h>
-
-#include <libjpeg/jpeg-marker.h>
+#include <libexif/i18n.h>
#include <libexif/olympus/exif-mnote-data-olympus.h>
#include <libexif/canon/exif-mnote-data-canon.h>
# define strncasecmp strnicmp
#endif
+#undef JPEG_MARKER_SOI
+#define JPEG_MARKER_SOI 0xd8
+#undef JPEG_MARKER_APP0
+#define JPEG_MARKER_APP0 0xe0
+#undef JPEG_MARKER_APP1
+#define JPEG_MARKER_APP1 0xe1
+
static const unsigned char ExifHeader[] = {0x45, 0x78, 0x69, 0x66, 0x00, 0x00};
struct _ExifDataPrivate
}
static int
-cmp_be_func (const void *elem1, const void *elem2)
+cmp_func_intel (const void *elem1, const void *elem2)
{
return cmp_func ((const unsigned char *) elem1,
(const unsigned char *) elem2, EXIF_BYTE_ORDER_INTEL);
}
static int
-cmp_le_func (const void *elem1, const void *elem2)
+cmp_func_motorola (const void *elem1, const void *elem2)
{
return cmp_func ((const unsigned char *) elem1,
(const unsigned char *) elem2, EXIF_BYTE_ORDER_MOTOROLA);
/* Sort the directory according to TIFF specification */
qsort (*d + 6 + offset - (ifd->count + n_ptr + n_thumb) * 12,
(ifd->count + n_ptr + n_thumb), 12,
- data->priv->order == EXIF_BYTE_ORDER_INTEL ? cmp_be_func : cmp_le_func);
+ data->priv->order == EXIF_BYTE_ORDER_INTEL ? cmp_func_intel : cmp_func_motorola);
/* Correctly terminate the directory */
if (i == EXIF_IFD_0 && (data->ifd[EXIF_IFD_1]->count ||
return EXIF_DATA_TYPE_MAKER_NOTE_NONE;
}
+#define LOG_TOO_SMALL \
+exif_log (data->priv->log, EXIF_LOG_CODE_CORRUPT_DATA, "ExifData", \
+ _("Size of data too small to allow for EXIF data."));
+
void
exif_data_load_data (ExifData *data, const unsigned char *d_orig,
unsigned int ds_orig)
* not, search the EXIF marker.
*/
if (ds < 6) {
- exif_log (data->priv->log, EXIF_LOG_CODE_DEBUG, "ExifData",
- "Size too small.");
+ LOG_TOO_SMALL;
return;
}
if (!memcmp (d, ExifHeader, 6)) {
break;
/* Unknown marker or data. Give up. */
- exif_log (data->priv->log, EXIF_LOG_CODE_DEBUG,
- "ExifData", "EXIF marker not found.");
+ exif_log (data->priv->log, EXIF_LOG_CODE_CORRUPT_DATA,
+ "ExifData", _("EXIF marker not found."));
return;
}
d++;
ds--;
if (ds < 2) {
- exif_log (data->priv->log, EXIF_LOG_CODE_DEBUG,
- "ExifData", "Size too small.");
+ LOG_TOO_SMALL;
return;
}
len = (d[0] << 8) | d[1];
* (offset 2, length 6).
*/
if (ds < 6) {
- exif_log (data->priv->log, EXIF_LOG_CODE_DEBUG, "ExifData",
- "Size too small.");
+ LOG_TOO_SMALL;
return;
}
if (memcmp (d, ExifHeader, 6)) {
- exif_log (data->priv->log, EXIF_LOG_CODE_DEBUG, "ExifData",
- "EXIF header not found.");
+ exif_log (data->priv->log, EXIF_LOG_CODE_CORRUPT_DATA,
+ "ExifData", _("EXIF header not found."));
return;
}
data->priv->order = EXIF_BYTE_ORDER_INTEL;
else if (!memcmp (d + 6, "MM", 2))
data->priv->order = EXIF_BYTE_ORDER_MOTOROLA;
- else
+ else {
+ exif_log (data->priv->log, EXIF_LOG_CODE_CORRUPT_DATA,
+ "ExifData", _("Unknown encoding."));
return;
+ }
/* Fixed value */
if (exif_get_short (d + 8, data->priv->order) != 0x002a)
/* Sanity check. */
if (offset > ds - 6) {
- exif_log (data->priv->log, EXIF_LOG_CODE_DEBUG,
- "ExifData", "Bogus offset!");
+ exif_log (data->priv->log, EXIF_LOG_CODE_CORRUPT_DATA,
+ "ExifData", "Bogus offset.");
return;
}