Update of /cvsroot/libexif/libexif/libexif In directory sc8-pr-cvs1:/tmp/cvs-serv29825 Modified Files: exif-content.h exif-data.c exif-entry.c exif-entry.h exif-mnote-data-priv.h exif-mnote-data.c exif-mnote-data.h Log Message: 1) Two new arguments (char *val, unsinged int maxlen) added to the following functions and macros: exif_entry_get_value exif_entry_get_value_brief exif_mnote_data_get_value exif_mnote_data_pentax_get_value macros: exif_content_get_value exif_content_get_value_brief The functions return either NULL (in case of error) or val. 2) All static variables eliminated. 3) memset(val, 0, maxlen); is in all functions, followed by maxlen--; which ensures all returned strings will always be NULL-terminated. All this should make the library thread-safe. Index: exif-content.h =================================================================== RCS file: /cvsroot/libexif/libexif/libexif/exif-content.h,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- exif-content.h 15 Dec 2002 11:41:11 -0000 1.7 +++ exif-content.h 7 Jan 2004 15:12:11 -0000 1.8 @@ -59,12 +59,12 @@ void *user_data); /* For your convenience */ -#define exif_content_get_value(c,t) \ +#define exif_content_get_value(c,t,v,m) \ (exif_content_get_entry (c,t) ? \ - exif_entry_get_value (exif_content_get_entry (c,t)) : NULL) -#define exif_content_get_value_brief(c,t) \ + exif_entry_get_value (exif_content_get_entry (c,t),v,m) : NULL) +#define exif_content_get_value_brief(c,t,v,m) \ (exif_content_get_entry (c,t) ? \ - exif_entry_get_value_brief (exif_content_get_entry (c,t)) : NULL) + exif_entry_get_value_brief (exif_content_get_entry (c,t),v,m) : NULL) void exif_content_dump (ExifContent *content, unsigned int indent); Index: exif-mnote-data-priv.h =================================================================== RCS file: /cvsroot/libexif/libexif/libexif/exif-mnote-data-priv.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- exif-mnote-data-priv.h 27 Oct 2003 22:34:29 -0000 1.3 +++ exif-mnote-data-priv.h 7 Jan 2004 15:12:12 -0000 1.4 @@ -45,7 +45,7 @@ const char * (* get_name) (ExifMnoteData *, unsigned int); const char * (* get_title) (ExifMnoteData *, unsigned int); const char * (* get_description) (ExifMnoteData *, unsigned int); - char * (* get_value) (ExifMnoteData *, unsigned int); + char * (* get_value) (ExifMnoteData *, unsigned int, char *val, unsigned int maxlen); }; typedef struct _ExifMnoteDataPriv ExifMnoteDataPriv; Index: exif-mnote-data.h =================================================================== RCS file: /cvsroot/libexif/libexif/libexif/exif-mnote-data.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- exif-mnote-data.h 26 Oct 2003 10:06:17 -0000 1.1 +++ exif-mnote-data.h 7 Jan 2004 15:12:12 -0000 1.2 @@ -39,8 +39,8 @@ const char *exif_mnote_data_get_title (ExifMnoteData *, unsigned int); const char *exif_mnote_data_get_description (ExifMnoteData *, unsigned int); -/* Free the result! */ -char *exif_mnote_data_get_value (ExifMnoteData *, unsigned int); +/* Returns NULL or val */ +char *exif_mnote_data_get_value (ExifMnoteData *, unsigned int, char *val, unsigned int maxlen); #ifdef __cplusplus } Index: exif-entry.c =================================================================== RCS file: /cvsroot/libexif/libexif/libexif/exif-entry.c,v retrieving revision 1.42 retrieving revision 1.43 diff -u -d -r1.42 -r1.43 --- exif-entry.c 9 Dec 2003 19:49:59 -0000 1.42 +++ exif-entry.c 7 Jan 2004 15:12:12 -0000 1.43 @@ -35,8 +35,6 @@ #undef MIN #define MIN(a, b) (((a) < (b)) ? (a) : (b)) -static const unsigned char ExifHeader[] = {0x45, 0x78, 0x69, 0x66, 0x00, 0x00}; - struct _ExifEntryPrivate { unsigned int ref_count; @@ -98,6 +96,7 @@ exif_entry_dump (ExifEntry *e, unsigned int indent) { [...1370 lines suppressed...] break; case 0x0007: - strncpy (v, _("w. strobe"), sizeof (v)); + strncpy (val, _("w. strobe"), maxlen); break; default: - return (exif_entry_get_value (e)); + return (exif_entry_get_value (e, val, maxlen)); } break; default: - return (exif_entry_get_value (e)); + return (exif_entry_get_value (e, val, maxlen)); } - return (v); + return (val); } void Index: exif-entry.h =================================================================== RCS file: /cvsroot/libexif/libexif/libexif/exif-entry.h,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- exif-entry.h 15 Dec 2002 11:41:11 -0000 1.8 +++ exif-entry.h 7 Jan 2004 15:12:12 -0000 1.9 @@ -54,8 +54,8 @@ void exif_entry_initialize (ExifEntry *entry, ExifTag tag); /* For your convenience */ -const char *exif_entry_get_value (ExifEntry *entry); -const char *exif_entry_get_value_brief (ExifEntry *entry); +const char *exif_entry_get_value (ExifEntry *entry, char *val, unsigned int maxlen); +const char *exif_entry_get_value_brief (ExifEntry *entry, char *val, unsigned int maxlen); void exif_entry_dump (ExifEntry *entry, unsigned int indent); Index: exif-data.c =================================================================== RCS file: /cvsroot/libexif/libexif/libexif/exif-data.c,v retrieving revision 1.34 retrieving revision 1.35 diff -u -d -r1.34 -r1.35 --- exif-data.c 1 Dec 2003 18:09:28 -0000 1.34 +++ exif-data.c 7 Jan 2004 15:12:11 -0000 1.35 @@ -665,9 +665,10 @@ else { em = exif_data_get_entry (data, EXIF_TAG_MAKE); if (em) { + char value[7]; /* Canon */ - if (!strcmp (exif_entry_get_value (em), "Canon")) + if (!strcmp (exif_entry_get_value (em, value, sizeof(value)), "Canon")) data->priv->md = exif_mnote_data_canon_new (); } } @@ -749,7 +750,7 @@ loader = exif_loader_new (); while (1) { - size = fread (data, 1, 1024, f); + size = fread (data, 1, sizeof (data), f); if (size <= 0) break; if (!exif_loader_write (loader, data, size)) break; } Index: exif-mnote-data.c =================================================================== RCS file: /cvsroot/libexif/libexif/libexif/exif-mnote-data.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- exif-mnote-data.c 27 Oct 2003 20:07:11 -0000 1.3 +++ exif-mnote-data.c 7 Jan 2004 15:12:12 -0000 1.4 @@ -128,8 +128,8 @@ } char * -exif_mnote_data_get_value (ExifMnoteData *d, unsigned int n) +exif_mnote_data_get_value (ExifMnoteData *d, unsigned int n, char *val, unsigned int maxlen) { if (!d || !d->methods.get_value) return NULL; - return d->methods.get_value (d, n); + return d->methods.get_value (d, n, val, maxlen); } |