OLD | NEW |
1 /* exif-entry.c | 1 /* exif-entry.c |
2 * | 2 * |
3 * Copyright (c) 2001 Lutz Mueller <lutz@users.sourceforge.net> | 3 * Copyright (c) 2001 Lutz Mueller <lutz@users.sourceforge.net> |
4 * | 4 * |
5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
6 * modify it under the terms of the GNU Lesser General Public | 6 * modify it under the terms of the GNU Lesser General Public |
7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
9 * | 9 * |
10 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
(...skipping 1333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1344 snprintf (val, maxlen, _("Unknown value %i"), v_short); | 1344 snprintf (val, maxlen, _("Unknown value %i"), v_short); |
1345 else | 1345 else |
1346 strncpy (val, _(list[i].strings[j]), maxlen); | 1346 strncpy (val, _(list[i].strings[j]), maxlen); |
1347 break; | 1347 break; |
1348 | 1348 |
1349 case EXIF_TAG_XP_TITLE: | 1349 case EXIF_TAG_XP_TITLE: |
1350 case EXIF_TAG_XP_COMMENT: | 1350 case EXIF_TAG_XP_COMMENT: |
1351 case EXIF_TAG_XP_AUTHOR: | 1351 case EXIF_TAG_XP_AUTHOR: |
1352 case EXIF_TAG_XP_KEYWORDS: | 1352 case EXIF_TAG_XP_KEYWORDS: |
1353 case EXIF_TAG_XP_SUBJECT: | 1353 case EXIF_TAG_XP_SUBJECT: |
1354 » » /* Warning! The texts are converted from UTF16 to UTF8 */ | 1354 { |
1355 » » /* FIXME: use iconv to convert into the locale encoding */ | 1355 /* Sanity check the size to prevent overflow */ |
1356 » » exif_convert_utf16_to_utf8(val, (unsigned short*)e->data, MIN(ma
xlen, e->size)); | 1356 if (e->size+sizeof(unsigned short) < e->size) break; |
1357 » » break; | 1357 |
| 1358 /* The tag may not be U+0000-terminated , so make a local |
| 1359 U+0000-terminated copy before converting it */ |
| 1360 unsigned short *utf16 = exif_mem_alloc (e->priv->mem, e->size+si
zeof(unsigned short)); |
| 1361 if (!utf16) break; |
| 1362 memcpy(utf16, e->data, e->size); |
| 1363 utf16[e->size/sizeof(unsigned short)] = 0; |
| 1364 |
| 1365 /* Warning! The texts are converted from UTF16 to UTF8 */ |
| 1366 /* FIXME: use iconv to convert into the locale encoding */ |
| 1367 exif_convert_utf16_to_utf8(val, utf16, maxlen); |
| 1368 exif_mem_free(e->priv->mem, utf16); |
| 1369 break; |
| 1370 } |
1358 | 1371 |
1359 default: | 1372 default: |
1360 /* Use a generic value formatting */ | 1373 /* Use a generic value formatting */ |
1361 exif_entry_format_value(e, val, maxlen); | 1374 exif_entry_format_value(e, val, maxlen); |
1362 } | 1375 } |
1363 | 1376 |
1364 return val; | 1377 return val; |
1365 } | 1378 } |
1366 | 1379 |
1367 | 1380 |
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1703 case EXIF_TAG_MAKER_NOTE: | 1716 case EXIF_TAG_MAKER_NOTE: |
1704 case EXIF_TAG_USER_COMMENT: | 1717 case EXIF_TAG_USER_COMMENT: |
1705 default: | 1718 default: |
1706 e->components = 0; | 1719 e->components = 0; |
1707 e->format = EXIF_FORMAT_UNDEFINED; | 1720 e->format = EXIF_FORMAT_UNDEFINED; |
1708 e->size = 0; | 1721 e->size = 0; |
1709 e->data = NULL; | 1722 e->data = NULL; |
1710 break; | 1723 break; |
1711 } | 1724 } |
1712 } | 1725 } |
OLD | NEW |