Update of /cvsroot/libexif/libexif/libexif/canon
In directory sc8-pr-cvs1:/tmp/cvs-serv4838/libexif/canon
Modified Files:
mnote-canon-entry.c
Log Message:
2003-12-09 Lutz Mueller <lu...@us...>
A couple of fixes by Jan Patera <pa...@pi...>:
* libexif
Index: mnote-canon-entry.c
===================================================================
RCS file: /cvsroot/libexif/libexif/libexif/canon/mnote-canon-entry.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- mnote-canon-entry.c 27 Oct 2003 22:34:30 -0000 1.3
+++ mnote-canon-entry.c 9 Dec 2003 19:49:59 -0000 1.4
@@ -32,6 +32,9 @@
/* #define DEBUG */
+#undef MIN
+#define MIN(a, b) (((a) < (b)) ? (a) : (b))
+
#define CF(format,target,v) \
{ \
if (format != target) { \
@@ -53,6 +56,16 @@
break; \
} \
}
+#define CC2(number,t1,t2,v) \
+{ \
+ if ((number != t1) && (number != t2)) { \
+ snprintf (v, sizeof (v), \
+ _("Invalid number of components (%i, " \
+ "expected %i or %i)."), (int) number, \
+ (int) t1, (int) t2); \
+ break; \
+ } \
+}
char *
mnote_canon_entry_get_value (const MnoteCanonEntry *entry)
@@ -511,13 +524,13 @@
case MNOTE_CANON_TAG_OWNER:
CF (entry->format, EXIF_FORMAT_ASCII, v);
CC (entry->components, 32, v);
- strncpy (v,data,sizeof (v));
+ strncpy (v,data,MIN (entry->size, sizeof (v) - 1));
break;
case MNOTE_CANON_TAG_FIRMWARE:
CF (entry->format, EXIF_FORMAT_ASCII, v);
- CC (entry->components, 24, v);
- strncpy (v,data,sizeof (v));
+ CC2 (entry->components, 24, 32, v);
+ strncpy (v,data,MIN (entry->size, sizeof (v) - 1));
break;
case MNOTE_CANON_TAG_IMAGE_NUMBER:
@@ -566,7 +579,7 @@
printf ("Value%d=%d\n", i, vs);
}
else if (entry->format == EXIF_FORMAT_ASCII)
- strncpy (v, data, sizeof (v));
+ strncpy (v,data,MIN (entry->size, sizeof (v) - 1));
#endif
break;
}
|