|
| 1 | +From 7e6c660a540fe0231bdd43017686211a9eacac8b Mon Sep 17 00:00:00 2001 |
| 2 | +From: Marcus Meissner <marcus@jet.franken.de> |
| 3 | +Date: Mon, 9 Mar 2026 10:02:53 +0100 |
| 4 | +Subject: [PATCH] check maxlen to be at least 1 |
| 5 | + |
| 6 | +maxlen-- on 0 will become a high value. |
| 7 | + |
| 8 | +(likely found by AI) |
| 9 | + |
| 10 | +Fixes https://github.com/libexif/libexif/issues/247 |
| 11 | + |
| 12 | +Signed-off-by: Azure Linux Security Servicing Account <azurelinux-security@microsoft.com> |
| 13 | +Upstream-reference: https://github.com/libexif/libexif/commit/7df372e9d31d7c993a22b913c813a5f7ec4f3692.patch |
| 14 | +--- |
| 15 | + libexif/apple/mnote-apple-entry.c | 2 ++ |
| 16 | + libexif/canon/mnote-canon-entry.c | 2 ++ |
| 17 | + libexif/fuji/mnote-fuji-entry.c | 1 + |
| 18 | + libexif/olympus/mnote-olympus-entry.c | 2 ++ |
| 19 | + libexif/pentax/mnote-pentax-entry.c | 1 + |
| 20 | + 5 files changed, 8 insertions(+) |
| 21 | + |
| 22 | +diff --git a/libexif/apple/mnote-apple-entry.c b/libexif/apple/mnote-apple-entry.c |
| 23 | +index 6740d8e..337e51b 100644 |
| 24 | +--- a/libexif/apple/mnote-apple-entry.c |
| 25 | ++++ b/libexif/apple/mnote-apple-entry.c |
| 26 | +@@ -43,6 +43,8 @@ mnote_apple_entry_get_value(MnoteAppleEntry *entry, char *v, unsigned int maxlen |
| 27 | + |
| 28 | + if (!entry) |
| 29 | + return NULL; |
| 30 | ++ if (maxlen < 1) |
| 31 | ++ return NULL; |
| 32 | + |
| 33 | + memset(v, 0, maxlen); |
| 34 | + maxlen--; |
| 35 | +diff --git a/libexif/canon/mnote-canon-entry.c b/libexif/canon/mnote-canon-entry.c |
| 36 | +index 52a7077..372fcdf 100644 |
| 37 | +--- a/libexif/canon/mnote-canon-entry.c |
| 38 | ++++ b/libexif/canon/mnote-canon-entry.c |
| 39 | +@@ -559,6 +559,8 @@ mnote_canon_entry_get_value (const MnoteCanonEntry *entry, unsigned int t, char |
| 40 | + |
| 41 | + if (!entry) |
| 42 | + return NULL; |
| 43 | ++ if (maxlen < 1) |
| 44 | ++ return NULL; |
| 45 | + |
| 46 | + data = entry->data; |
| 47 | + size = entry->size; |
| 48 | +diff --git a/libexif/fuji/mnote-fuji-entry.c b/libexif/fuji/mnote-fuji-entry.c |
| 49 | +index add7086..dd33900 100644 |
| 50 | +--- a/libexif/fuji/mnote-fuji-entry.c |
| 51 | ++++ b/libexif/fuji/mnote-fuji-entry.c |
| 52 | +@@ -199,6 +199,7 @@ mnote_fuji_entry_get_value (MnoteFujiEntry *entry, |
| 53 | + int i, j; |
| 54 | + |
| 55 | + if (!entry) return (NULL); |
| 56 | ++ if (maxlen < 1) return NULL; |
| 57 | + |
| 58 | + memset (val, 0, maxlen); |
| 59 | + maxlen--; |
| 60 | +diff --git a/libexif/olympus/mnote-olympus-entry.c b/libexif/olympus/mnote-olympus-entry.c |
| 61 | +index 679fb50..d5eb60e 100644 |
| 62 | +--- a/libexif/olympus/mnote-olympus-entry.c |
| 63 | ++++ b/libexif/olympus/mnote-olympus-entry.c |
| 64 | +@@ -284,6 +284,8 @@ mnote_olympus_entry_get_value (MnoteOlympusEntry *entry, char *v, unsigned int m |
| 65 | + |
| 66 | + if (!entry) |
| 67 | + return (NULL); |
| 68 | ++ if (maxlen < 1) |
| 69 | ++ return NULL; |
| 70 | + |
| 71 | + memset (v, 0, maxlen); |
| 72 | + maxlen--; |
| 73 | +diff --git a/libexif/pentax/mnote-pentax-entry.c b/libexif/pentax/mnote-pentax-entry.c |
| 74 | +index 32b537b..d3c96f8 100644 |
| 75 | +--- a/libexif/pentax/mnote-pentax-entry.c |
| 76 | ++++ b/libexif/pentax/mnote-pentax-entry.c |
| 77 | +@@ -315,6 +315,7 @@ mnote_pentax_entry_get_value (MnotePentaxEntry *entry, |
| 78 | + int i = 0, j = 0; |
| 79 | + |
| 80 | + if (!entry) return (NULL); |
| 81 | ++ if (maxlen < 1) return (NULL); |
| 82 | + |
| 83 | + memset (val, 0, maxlen); |
| 84 | + maxlen--; |
| 85 | +-- |
| 86 | +2.45.4 |
| 87 | + |
0 commit comments