null-terminate exif strings

libexif strings are not null-terminated, add a \0 before adding to the
vips image

thanks Mike
This commit is contained in:
John Cupitt 2013-07-06 11:51:34 +01:00
parent 7bf40144b9
commit 02095763c9
2 changed files with 13 additions and 2 deletions

View File

@ -1,6 +1,7 @@
3/7/13 started 7.34.2
- lower priority for Matlab load to reduce segvs from Mat_Open(), thanks
Michael
- null-terminate libexif strings, thanks Mike
28/6/13 started 7.34.1
- fix morphological operators on non-uchar images

View File

@ -53,6 +53,8 @@
* 21/11/12
* - don't insist exif must have data
* - attach IPCT data (app13), thanks Gary
* 6/7/13
* - null-terminate exif strings, thanks Mike
*/
/*
@ -407,8 +409,16 @@ vips_exif_to_s( ExifData *ed, ExifEntry *entry, VipsBuf *buf )
ExifSRational srv;
char txt[256];
if( entry->format == EXIF_FORMAT_ASCII )
vips_buf_appendf( buf, "%s ", entry->data );
if( entry->format == EXIF_FORMAT_ASCII ) {
/* libexif does not null-terminate strings. Copy out and add
* the \0 ourselves.
*/
int len = VIPS_MIN( 254, entry->size );
memcpy( txt, entry->data, len );
txt[len] = '\0';
vips_buf_appendf( buf, "%s ", txt );
}
else if( entry->components < 10 &&
!vips_exif_get_int( ed, entry, 0, &iv ) ) {
for( i = 0; i < entry->components; i++ ) {