~ubuntu-branches/ubuntu/hardy/libexif/hardy

« back to all changes in this revision

Viewing changes to libexif/canon/mnote-canon-entry.c

  • Committer: Bazaar Package Importer
  • Author(s): Nico Golde
  • Date: 2007-12-21 17:13:58 UTC
  • mfrom: (5.1.5 hardy)
  • Revision ID: james.westby@ubuntu.com-20071221171358-zbjzk21kmnizelhk
Tags: 0.6.16-2.1
* Non-maintainer upload by security team.
* This update addresses the following security issues:
  - possible denial of service attack via crafted
    image file leading to an infinite recursion in the
    exif-loader.c (CVE-2007-6351; Closes: #457330).
  - integer overflow in exif-data.c triggered by a crafted
    image file could lead to arbitrary code execution
    (CVE-2007-6352; Closes: #457330).

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
#include <stdio.h>
26
26
#include <stdlib.h>
27
27
#include <string.h>
 
28
#include <math.h>
28
29
 
29
30
#include <libexif/exif-format.h>
30
31
#include <libexif/exif-utils.h>
66
67
 
67
68
#define UNDEFINED 0xFF
68
69
    
69
 
static struct  {
 
70
static struct canon_entry_table_t {
70
71
  unsigned int subtag;
71
72
  ExifShort value;
72
73
  char *name;
73
 
} entries [] = {
74
 
  { 0,  1, N_("macro")},
75
 
  { 0,  2, N_("normal")},
76
 
  { 3,  0, N_("flash did not fire")},
77
 
  { 3,  1, N_("auto")},
78
 
  { 3,  2, N_("on")},
79
 
  { 3,  3, N_("red eyes reduction")},
80
 
  { 3,  4, N_("slow synchro")},
81
 
  { 3,  5, N_("auto + red yes reduction")},
82
 
  { 3,  6, N_("on + red eyes reduction")},
83
 
  { 3, 16, N_("external")},
84
 
  { 4,  0, N_("single or timer")},
85
 
  { 4,  1, N_("continuous")},
86
 
  { 6,  0, N_("one-Shot")},
87
 
  { 6,  1, N_("AI Servo")},
88
 
  { 6,  2, N_("AI Focus")},
89
 
  { 6,  3, N_("MF")},
 
74
} entries_settings_1 [] = {
 
75
  { 0,  1, N_("Macro")},
 
76
  { 0,  2, N_("Normal")},
 
77
  { 2,  1, N_("Economy")},
 
78
  { 2,  2, N_("Normal")},  
 
79
  { 2,  3, N_("Fine")},
 
80
  { 2,  4, N_("RAW")},
 
81
  { 2,  5, N_("Superfine")},
 
82
  { 3,  0, N_("Off")},
 
83
  { 3,  1, N_("Auto")},
 
84
  { 3,  2, N_("On")},
 
85
  { 3,  3, N_("Red-eye reduction")},
 
86
  { 3,  4, N_("Slow synchro")},
 
87
  { 3,  5, N_("Auto + Red-eye reduction")},
 
88
  { 3,  6, N_("On + Red-eye reduction")},
 
89
  { 3, 16, N_("External flash")},
 
90
  { 4,  0, N_("Single")},
 
91
  { 4,  1, N_("Continuous")},
 
92
  { 4,  2, N_("Movie")},
 
93
  { 4,  3, N_("Continuous, speed priority")},
 
94
  { 4,  4, N_("Continuous, low")},
 
95
  { 4,  5, N_("Continuous, high")},
 
96
  { 6,  0, N_("One-shot AF")},
 
97
  { 6,  1, N_("AI servo AF")},
 
98
  { 6,  2, N_("AI focus AF")},
 
99
  { 6,  3, N_("Manual focus")}, 
90
100
  { 6,  4, N_("Single")},
91
101
  { 6,  5, N_("Continuous")},
92
 
  { 6,  6, N_("MF")},
93
 
  { 9,  0, N_("large")},
94
 
  { 9,  1, N_("medium")},
95
 
  { 9,  2, N_("small")},
96
 
  {10,  0, N_("full auto")},
97
 
        {10,  1, N_("manual")},
98
 
        {10,  2, N_("landscape")},
99
 
        {10,  3, N_("fast shutter")},
100
 
        {10,  4, N_("slow shutter")},
101
 
        {10,  5, N_("night")},
102
 
        {10,  6, N_("Black & White")},
 
102
  { 6,  6, N_("Manual focus")},
 
103
  { 6,  16, N_("Pan focus")},  
 
104
  { 9,  0, N_("Large")},
 
105
  { 9,  1, N_("Medium")},
 
106
  { 9,  2, N_("Small")},
 
107
  { 9,  5, N_("Medium 1")},
 
108
  { 9,  6, N_("Medium 2")},
 
109
  { 9,  7, N_("Medium 3")},  
 
110
  {10,  0, N_("Full auto")},
 
111
        {10,  1, N_("Manual")},
 
112
        {10,  2, N_("Landscape")},
 
113
        {10,  3, N_("Fast shutter")},
 
114
        {10,  4, N_("Slow shutter")},
 
115
        {10,  5, N_("Night")},
 
116
        {10,  6, N_("Grayscale")},
103
117
        {10,  7, N_("Sepia")},
104
118
        {10,  8, N_("Portrait")},
105
119
        {10,  9, N_("Sports")},
106
 
        {10, 10, N_("Macro / Close-Up")},
107
 
        {10, 11, N_("Pan Focus")},
108
 
        {12, 0x0000, N_("normal")},
109
 
        {12, 0x0001, N_("high")},
110
 
        {12, 0xffff, N_("low")},
111
 
        {13, 0x0000, N_("normal")},
112
 
        {13, 0x0001, N_("high")},
113
 
        {13, 0xffff, N_("low")},
114
 
        {14, 0x0000, N_("normal")},
115
 
        {14, 0x0001, N_("high")},
116
 
        {14, 0xffff, N_("low")},
117
 
        {15, 15, N_("auto")},
 
120
        {10, 10, N_("Macro")},
 
121
        {10, 11, N_("Black & white")},
 
122
        {10, 12, N_("Pan focus")},
 
123
        {10, 13, N_("Vivid")},
 
124
        {10, 14, N_("Neutral")},
 
125
        {10, 15, N_("Flash off")},
 
126
        {10, 16, N_("Long shutter")},
 
127
        {10, 17, N_("Super macro")},
 
128
        {10, 18, N_("Foliage")},
 
129
        {10, 19, N_("Indoor")},
 
130
        {10, 20, N_("Fireworks")},
 
131
        {10, 21, N_("Beach")},
 
132
        {10, 22, N_("Underwater")},
 
133
        {10, 23, N_("Snow")},
 
134
        {10, 24, N_("Kids & pets")},
 
135
        {10, 25, N_("Night snapshot")},
 
136
        {10, 26, N_("Digital macro")},
 
137
        {10, 27, N_("My colors")},
 
138
        {10, 28, N_("Still image")},
 
139
        {11, 0, N_("None")},
 
140
        {11, 1, N_("2x")},
 
141
        {11, 2, N_("4x")},
 
142
        {11, 3, N_("Other")},
 
143
        {12, 0x0000, N_("Normal")},
 
144
        {12, 0x0001, N_("High")},
 
145
        {12, 0xffff, N_("Low")},
 
146
        {13, 0x0000, N_("Normal")},
 
147
        {13, 0x0001, N_("High")},
 
148
        {13, 0xffff, N_("Low")},
 
149
        {14, 0x0000, N_("Normal")},
 
150
        {14, 0x0001, N_("High")},
 
151
        {14, 0xffff, N_("Low")},
 
152
        {15, 14, N_("Auto high")},
 
153
        {15, 15, N_("Auto")},
118
154
        {15, 16, N_("50")},
119
155
        {15, 17, N_("100")},
120
156
        {15, 18, N_("200")},
121
157
        {15, 19, N_("400")},
122
 
        {16,  3, N_("evaluative")},
123
 
        {16,  4, N_("partial")},
124
 
        {16,  5, N_("center-weighted")},
125
 
        {18, 0x3000, N_("none (manual focus)")},
126
 
        {18, 0x3001, N_("auto-selected")},
127
 
        {18, 0x3002, N_("right")},
128
 
        {18, 0x3003, N_("center")},
129
 
        {18, 0x3004, N_("left")},
130
 
        {19,  0, N_("easy shooting")},
131
 
        {19,  1, N_("program")},
 
158
        {15, 20, N_("800")},
 
159
        {16,  0, N_("Default")},
 
160
        {16,  1, N_("Spot")},
 
161
        {16,  2, N_("Average")},        
 
162
        {16,  3, N_("Evaluative")},
 
163
        {16,  4, N_("Partial")},
 
164
        {16,  5, N_("Center-weighted average")},
 
165
        {17,  0, N_("Manual")},
 
166
        {17,  1, N_("Auto")},
 
167
        {17,  2, N_("Not known")},
 
168
        {17,  3, N_("Macro")},
 
169
        {17,  4, N_("Very close")},
 
170
        {17,  5, N_("Close")},
 
171
        {17,  6, N_("Middle range")},
 
172
        {17,  7, N_("Far range")},
 
173
        {17,  8, N_("Pan focus")},
 
174
        {17,  9, N_("Super macro")},
 
175
        {17,  10, N_("Infinity")},
 
176
        {18, 0x2005, N_("Manual AF point selection")},
 
177
        {18, 0x3000, N_("None (MF)")},
 
178
        {18, 0x3001, N_("Auto-selected")},
 
179
        {18, 0x3002, N_("Right")},
 
180
        {18, 0x3003, N_("Center")},
 
181
        {18, 0x3004, N_("Left")},
 
182
        {18, 0x4001, N_("Auto AF point selection")},
 
183
        {19,  0, N_("Easy shooting")},
 
184
        {19,  1, N_("Program")},
132
185
        {19,  2, N_("Tv-priority")},
133
186
        {19,  3, N_("Av-priority")},
134
 
        {19,  4, N_("manual")},
 
187
        {19,  4, N_("Manual")},
135
188
        {19,  5, N_("A-DEP")},
 
189
        {19,  6, N_("M-DEP")},
136
190
        {21, 0x001, N_("Canon EF 50mm f/1.8")},
137
191
        {21, 0x002, N_("Canon EF 28mm f/2.8")},
138
192
        {21, 0x004, N_("Sigma UC Zoom 35-135mm f/4-5.6")},
184
238
        {21, 0x229, N_("Canon EF 16-35mm f/2.8L")},
185
239
        {21, 0x230, N_("Canon EF 24-70mm f/2.8L")},
186
240
        {21, 0x231, N_("Canon EF 17-40mm f/4L")},
187
 
  {31,  0, N_("single")},
188
 
  {31,  1, N_("continuous")},
 
241
        {28, 0, N_("Manual")},
 
242
        {28, 1, N_("TTL")},
 
243
        {28, 2, N_("A-TTL")},
 
244
        {28, 3, N_("E-TTL")},
 
245
        {28, 4, N_("FP sync enabled")},
 
246
        {28, 7, N_("2nd-curtain sync used")},
 
247
        {28, 11, N_("FP sync used")},
 
248
        {28, 13, N_("Internal")},
 
249
        {28, 14, N_("External")},
 
250
  {31,  0, N_("Single")},
 
251
  {31,  1, N_("Continuous")},
 
252
        {32, 0, N_("Normal AE")},
 
253
        {32, 1, N_("Exposure compensation")},
 
254
        {32, 2, N_("AE lock")},
 
255
        {32, 3, N_("AE lock + Exposure compensation")},
 
256
        {32, 4, N_("No AE")},
 
257
        {33, 0, N_("Off")},
 
258
        {33, 1, N_("On")},
 
259
        {33, 2, N_("On, shot only")},
 
260
        {39, 0, N_("Off")},
 
261
        {39, 1, N_("Vivid")},
 
262
        {39, 2, N_("Neutral")},
 
263
        {39, 3, N_("Smooth")},
 
264
        {39, 4, N_("Sepia")},
 
265
        {39, 5, N_("Black & white")},
 
266
        {39, 6, N_("Custom")},
 
267
        {39, 100, N_("My color data")},
 
268
        {40, 0, N_("Off")},
 
269
        {40, 0x0500, N_("Full")},
 
270
        {40, 0x0502, N_("2/3")},
 
271
        {40, 0x0504, N_("1/3")},
189
272
  { 0,  0, NULL}
 
273
},
 
274
entries_focal_length [] = {
 
275
        {0, 1, N_("Fixed")},
 
276
        {0, 2, N_("Zoom")},
 
277
        {0, 0, NULL}
 
278
},
 
279
entries_settings_2 [] = {
 
280
  { 6,  0, N_("Auto")},
 
281
  { 6,  1, N_("Sunny")},
 
282
  { 6,  2, N_("Cloudy")},
 
283
  { 6,  3, N_("Tungsten")},
 
284
  { 6,  4, N_("Fluorescent")},
 
285
  { 6,  5, N_("Flash")},
 
286
  { 6,  6, N_("Custom")},
 
287
  { 6,  7, N_("Black & white")},
 
288
  { 6,  8, N_("Shade")},
 
289
  { 6,  9, N_("Manual temperature (Kelvin)")},
 
290
  { 6,  10, N_("PC set 1")},
 
291
  { 6,  11, N_("PC set 2")},
 
292
  { 6,  12, N_("PC set 3")},
 
293
  { 6,  14, N_("Daylight fluorescent")},
 
294
  { 6,  15, N_("Custom 1")},
 
295
  { 6,  16, N_("Custom 2")},
 
296
  { 6,  17, N_("Underwater")},
 
297
  { 7,  0, N_("Off")},
 
298
  { 7,  1, N_("Night scene")},
 
299
  { 7,  2, N_("On")},
 
300
  { 7,  3, N_("None")},
 
301
  { 13,  0x3000, N_("None (MF)")},
 
302
  { 13,  0x3001, N_("Right")},
 
303
  { 13,  0x3002, N_("Center")},
 
304
  { 13,  0x3003, N_("Center + Right")},
 
305
  { 13,  0x3004, N_("Left")},
 
306
  { 13,  0x3005, N_("Left + Right")},
 
307
  { 13,  0x3006, N_("Left + Center")},
 
308
  { 13,  0x3007, N_("All")},
 
309
  { 15,  0, N_("Off")},
 
310
  { 15,  1, N_("On (shot 1)")},
 
311
  { 15,  2, N_("On (shot 2)")},
 
312
  { 15,  3, N_("On (shot 3)")},
 
313
  { 15,  0xffff, N_("On")},
 
314
  { 25,  248, N_("EOS high-end")},
 
315
  { 25,  250, N_("Compact")},
 
316
  { 25,  252, N_("EOS mid-range")},
 
317
  { 26,  0, N_("None")},
 
318
  { 26,  1, N_("Rotate 90 CW")},
 
319
  { 26,  2, N_("Rotate 180")},
 
320
  { 26,  3, N_("Rotate 270 CW")},
 
321
  { 26,  0xffff, N_("Rotated by software")},
 
322
  { 27,  0, N_("Off")},
 
323
  { 27,  1, N_("On")},  
 
324
        {32, 0, N_("Off")},
 
325
        {32, 0x0014, N_("1/3")},
 
326
        {32, 0x008c, N_("2/3")},
 
327
        {32, 0x07d0, N_("Full")},
 
328
        {0, 0, NULL}
 
329
},
 
330
entries_panorama [] = {
 
331
        {0, 0, N_("Left to right")},
 
332
        {0, 1, N_("Right to left")},
 
333
        {0, 2, N_("Bottom to top")},
 
334
        {0, 3, N_("Top to bottom")},
 
335
        {0, 4, N_("2x2 matrix (clockwise)")},
 
336
        {0, 0, NULL}
190
337
};
191
338
 
 
339
static void
 
340
canon_search_table_value (struct canon_entry_table_t table[],
 
341
    unsigned int t, ExifShort vs, char *val, unsigned int maxlen)
 
342
{
 
343
        unsigned int j;
 
344
 
 
345
        /* Search the table for the first matching subtag and value. */
 
346
        for (j = 0; table[j].name && ((table[j].subtag < t) ||
 
347
                        ((table[j].subtag == t) && table[j].value <= vs)); j++) {
 
348
                if ((table[j].subtag == t) && (table[j].value == vs)) {
 
349
                        break;
 
350
                }
 
351
        }
 
352
        if ((table[j].subtag == t) && (table[j].value == vs) && table[j].name) {
 
353
    /* Matching subtag and value found. */
 
354
                strncpy (val, table[j].name, maxlen);
 
355
        } else {
 
356
                /* No matching subtag and/or value found. */
 
357
                snprintf (val, maxlen, "0x%04x", vs);
 
358
        }
 
359
}
 
360
 
 
361
static void
 
362
canon_search_table_bitfield (struct canon_entry_table_t table[],
 
363
    unsigned int t, ExifShort vs, char *val, unsigned int maxlen)
 
364
{
 
365
        unsigned int j;
 
366
 
 
367
        /* Search the table for the first matching subtag. */
 
368
        for (j = 0; table[j].name && (table[j].subtag <= t); j++) {
 
369
                if (table[j].subtag == t) {
 
370
                        break;
 
371
                }
 
372
        }
 
373
        if ((table[j].subtag == t) && table[j].name) {
 
374
                unsigned int i, bit, lastbit = 0;
 
375
 
 
376
                /*
 
377
     * Search the table for the last matching bit, because
 
378
     * that one needs no additional comma appended.
 
379
     */
 
380
                for (i = j; table[i].name && (table[i].subtag == t); i++) {
 
381
                        bit = table[i].value;
 
382
                        if ((vs >> bit) & 1) {
 
383
                                lastbit = bit;
 
384
                        }
 
385
                }
 
386
                /* Search the table for all matching bits. */
 
387
                for (i = j; table[i].name && (table[i].subtag == t); i++) {
 
388
                        bit = table[i].value;
 
389
                        if ((vs >> bit) & 1) {
 
390
                                strncat(val, table[i].name, maxlen - strlen (val));
 
391
                                if (bit != lastbit) 
 
392
                                        strncat (val, N_(", "), maxlen - strlen (val));
 
393
                        }
 
394
                }
 
395
        } else {
 
396
                /* No matching subtag found. */
 
397
                snprintf (val, maxlen, "0x%04x", vs);
 
398
        }
 
399
}
 
400
 
192
401
unsigned int
193
402
mnote_canon_entry_count_values (const MnoteCanonEntry *entry)
194
403
{
197
406
        if (!entry) return 0;
198
407
 
199
408
        switch (entry->tag) {
 
409
        case MNOTE_CANON_TAG_FOCAL_LENGTH:
 
410
        case MNOTE_CANON_TAG_PANORAMA:
 
411
                return entry->components;
200
412
        case MNOTE_CANON_TAG_SETTINGS_1:
201
413
        case MNOTE_CANON_TAG_SETTINGS_2:
202
414
        case MNOTE_CANON_TAG_CUSTOM_FUNCS:
210
422
        }
211
423
}
212
424
 
 
425
/*
 
426
 * For reference, see Exif 2.1 specification (Appendix C), 
 
427
 * or http://en.wikipedia.org/wiki/APEX_system
 
428
 */
 
429
static double
 
430
apex_value_to_aperture (double x)
 
431
{
 
432
        return pow (2, x / 2.);
 
433
}
 
434
 
 
435
static double
 
436
apex_value_to_shutter_speed(double x)
 
437
{
 
438
        return 1.0 / pow (2, x);
 
439
}
 
440
 
 
441
static double
 
442
apex_value_to_iso_speed (double x)
 
443
{
 
444
        return 3.125 * pow (2, x);
 
445
}
 
446
 
213
447
char *
214
448
mnote_canon_entry_get_value (const MnoteCanonEntry *entry, unsigned int t, char *val, unsigned int maxlen)
215
449
{
216
450
        char buf[128];
217
451
        ExifLong vl;
218
452
        ExifShort vs, n;
219
 
        unsigned int j;
220
 
        unsigned char *data = entry->data;
221
 
 
222
 
        if (!entry) return NULL;
 
453
        unsigned char *data;
 
454
        double d;
 
455
 
 
456
        if (!entry) 
 
457
                return NULL;
 
458
 
 
459
        data = entry->data;
223
460
 
224
461
        memset (val, 0, maxlen);
225
462
        maxlen--;
233
470
                vs = exif_get_short (entry->data + 2 + t * 2, entry->order);
234
471
                switch (t) {
235
472
                case 1:
236
 
                        if (!vs) break;
237
 
                        snprintf (buf, sizeof (buf), _("%i (ms)"), vs * 100);
238
 
                        strncpy (val, buf, maxlen - strlen (val));
 
473
                        if (!vs) {
 
474
                                strncpy(val, _("Off"), maxlen);
 
475
                                break;
 
476
                        }
 
477
                        snprintf (val, maxlen, _("%i (ms)"), vs * 100);
 
478
                        break;
 
479
                case 15:
 
480
                        if (((vs & 0xC000) == 0x4000) && (vs != 0x7FFF)) {
 
481
                                /* Canon S3 IS - directly specified value */
 
482
                                snprintf (val, maxlen, _("%i"), vs & ~0x4000);
 
483
                        } else {
 
484
                                /* Standard Canon - index into lookup table */
 
485
                                canon_search_table_value (entries_settings_1, t, vs, val, maxlen);
 
486
                        }
239
487
                        break;
240
488
                case 22:
241
489
                case 23:
242
 
                        snprintf (buf, sizeof (buf), "%u", vs);
243
 
                        strncpy (val, buf, maxlen - strlen (val));
244
 
                        break;
245
490
                case 24:
246
 
                        snprintf (buf, sizeof (buf), _("%u mm"), vs);
247
 
                        strncpy (val, buf, maxlen - strlen(val));
 
491
                        snprintf (val, maxlen, "%u", vs);
 
492
                        break;
 
493
                case 25:
 
494
                case 26:
 
495
                        snprintf (val, maxlen, "%.2f", apex_value_to_aperture (vs / 32.0));
248
496
                        break;
249
497
                case 28:
250
 
                        if ((vs >> 14) & 1)
251
 
                                strncpy (val, _("External E-TTL"), maxlen - strlen (val));
252
 
                        if ((vs >> 13) & 1)
253
 
                                strncpy (val, _("Internal flash"), maxlen - strlen (val));
254
 
                        if ((vs >> 11) & 1)
255
 
                                strncpy (val, _("FP sync used"), maxlen - strlen (val));
256
 
                        if ((vs >> 4) & 1)
257
 
                                strncpy (val, _("FP sync enabled"), maxlen - strlen (val));
258
 
                        break;
 
498
                        canon_search_table_bitfield(entries_settings_1, t, vs, val, maxlen);
 
499
                        break;
 
500
                case 34:
 
501
                        snprintf (val, maxlen, "%.2f", vs / 10.0);
 
502
                        break;
 
503
                case 35:
 
504
                case 36:
 
505
                        snprintf (val, maxlen, "%u", vs);
 
506
                        break;
 
507
                default:
 
508
                        canon_search_table_value (entries_settings_1, t, vs, val, maxlen);
 
509
                }
 
510
                break;
259
511
 
 
512
        case MNOTE_CANON_TAG_FOCAL_LENGTH:
 
513
                CF (entry->format, EXIF_FORMAT_SHORT, val, maxlen);
 
514
                vs = exif_get_short (entry->data + t * 2, entry->order);
 
515
                switch (t) {
 
516
                case 1:
 
517
                        snprintf (val, maxlen, "%u", vs);
 
518
                        break;
 
519
                case 2:
 
520
                case 3:
 
521
                        snprintf (val, maxlen, _("%.2f mm"), vs * 25.4 / 1000);
 
522
                        break;
260
523
                default:
261
 
                        for (j = 0; entries[j].name && ((entries[j].subtag < t) ||
262
 
                                                ((entries[j].subtag == t) && entries[j].value <= vs)); j++)
263
 
                                if ((entries[j].subtag == t) && (entries[j].value == vs)) break;
264
 
                        if ((entries[j].subtag == t) &&
265
 
                                        (entries[j].value == vs) && entries[j].name)
266
 
                                strncpy (val, entries[j]. name, maxlen - strlen (val));
267
 
                        else {
268
 
                                snprintf (buf, sizeof (buf), "0x%04x", vs);
269
 
                                strncpy (val, buf, maxlen - strlen (val));
270
 
                        }
 
524
                        canon_search_table_value (entries_focal_length, t, vs, val, maxlen);
271
525
                }
272
526
                break;
273
527
 
278
532
                CC (entry->components, n, val, maxlen);
279
533
                vs = exif_get_short (entry->data + 2 + t * 2, entry->order);
280
534
                switch (t) {
281
 
                case 6:
282
 
                        switch (vs) {
283
 
                        case 0:
284
 
                                strncpy (val, _("Auto"), maxlen - strlen (val));
285
 
                                break;
286
 
                        case 1:
287
 
                                strncpy (val, _("Sunny"), maxlen - strlen (val));
288
 
                                break;
289
 
                        case 2:
290
 
                                strncpy (val, _("Cloudy"), maxlen - strlen (val));
291
 
                                break;
292
 
                        case 3:
293
 
                                strncpy (val, _("Tungsten"), maxlen - strlen (val));
294
 
                                break;
295
 
                        case 4:
296
 
                                strncpy (val, _("Flourescent"), maxlen - strlen (val));
297
 
                                break;
298
 
                        case 5:
299
 
                                strncpy (val, _("Flash"), maxlen - strlen (val));
300
 
                                break;
301
 
                        case 6:
302
 
                                strncpy (val, _("Custom"), maxlen - strlen (val));
303
 
                                break;
304
 
                        default:
305
 
                                snprintf (buf, sizeof (buf), "%i", vs);
306
 
                                strncpy (val, buf, maxlen - strlen (val));
307
 
                        }
 
535
                case 0:
 
536
                case 1:
 
537
                        snprintf (val, maxlen, "%.0f", apex_value_to_iso_speed(vs / 32.0));
 
538
                        break;
 
539
                case 2:
 
540
                case 5:
 
541
                case 14:
 
542
                case 16:
 
543
                        snprintf (val, maxlen, _("%.2f EV"), vs / 32.0);
 
544
                        break;
 
545
                case 3:
 
546
                case 20:
 
547
                        snprintf (val, maxlen, "%.2f", apex_value_to_aperture (vs / 32.0));
 
548
                        break;
 
549
                case 4:
 
550
                case 21:
 
551
                        d = apex_value_to_shutter_speed(vs / 32.0);
 
552
                        if (d < 1)
 
553
                                snprintf (val, maxlen, _("1/%d"),(int)(1.0 / d));
 
554
                        else
 
555
                                snprintf (val, maxlen, _("%d"), (int) d);
308
556
                        break;
309
557
                case 8:
310
 
                        snprintf (buf, sizeof (buf), "%u", vs);
311
 
                        strncpy (val, buf, maxlen - strlen (val));
312
 
                        break;
313
 
                case 13:
314
 
                        if (vs >> 12) {
315
 
                                if (vs & 1)
316
 
                                        strncpy (val, _("right"), maxlen - strlen (val));
317
 
                                if ((vs >> 1) & 1)
318
 
                                        strncpy (val, _("center"), maxlen - strlen (val));
319
 
                                if ((vs >> 2) & 1)
320
 
                                        strncpy (val, _("left"), maxlen - strlen (val));
321
 
                                if (vs >> 12 == 1)
322
 
                                        snprintf (buf, sizeof (buf), _(" (1 available focus point)"));
323
 
                                else
324
 
                                        snprintf (buf, sizeof (buf), _(" (%u available focus points)"), vs >> 12);
325
 
                                strncat (val, buf, maxlen - strlen (val));
326
 
                        }
327
 
                        break;
328
 
                case 14:
329
 
                        snprintf (buf, sizeof (buf), _("%.2f EV"), vs / 32.);
330
 
                        strncpy (val, buf, maxlen - strlen (val));
 
558
                        snprintf (val, maxlen, "%u", vs);
 
559
                        break;
 
560
                case 12:
 
561
                        snprintf (val, maxlen, "%.2f", vs / 32.0);
331
562
                        break;
332
563
                case 18:
333
 
                        snprintf (buf, sizeof (buf), _("%u mm"), vs);
334
 
                        strncpy (val, buf, maxlen - strlen (val));
 
564
                case 19:
 
565
                        snprintf (val, maxlen, _("%u mm"), vs);
 
566
                        break;
 
567
                case 28:
 
568
                        if (!vs) {
 
569
                                strncpy(val, _("Off"), maxlen);
 
570
                                break;
 
571
                        }
 
572
                        snprintf (val, maxlen, _("%i (ms)"), vs * 100);
335
573
                        break;
336
574
                default:
337
 
                        snprintf (buf, sizeof (buf), "0x%04x", vs);
338
 
                        strncpy (val, buf, maxlen - strlen (val));
339
 
                        break;
 
575
                        canon_search_table_value (entries_settings_2, t, vs, val, maxlen);
340
576
                }
341
577
                break;
342
578
 
 
579
        case MNOTE_CANON_TAG_PANORAMA:
 
580
                CF (entry->format, EXIF_FORMAT_SHORT, val, maxlen);
 
581
                vs = exif_get_short (entry->data + t * 2, entry->order);
 
582
                canon_search_table_value (entries_panorama, t, vs, val, maxlen);
 
583
                break;
 
584
 
343
585
        case MNOTE_CANON_TAG_OWNER:
344
586
                CC (entry->components, 32, val, maxlen);
345
587
                /* Fall through; ImageType can have many sizes */