Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DecodeMacRoman() is missing an upper bounds check before indexing into Mac2Unicode array #891

Closed
ddkilzer opened this issue Aug 27, 2020 · 4 comments
Labels

Comments

@ddkilzer
Copy link

DecodeMacRoman() is missing an upper bounds check before indexing into the Mac2Unicode array:

/* Function to convert from MacRoman to Unicode */
uint TY_(DecodeMacRoman)(uint c)
{
    if (127 < c)
        c = Mac2Unicode[c - 128];
    return c;
}

It should do this instead, like DecodeIbm850() does:

    if (127 < c && c < 256)
        c = Mac2Unicode[c - 128];
    return c;
@geoffmcl
Copy link
Contributor

@ddkilzer I like your upper bounds check...

Does this patch work for you?

diff --git a/src/streamio.c b/src/streamio.c
index d23f056..ed3f396 100644
--- a/src/streamio.c
+++ b/src/streamio.c
@@ -724,7 +724,7 @@ static const uint Mac2Unicode[128] =
 /* Function to convert from MacRoman to Unicode */
 uint TY_(DecodeMacRoman)(uint c)
 {
-    if (127 < c)
+    if (127 < c && c < 256) // is. #891
         c = Mac2Unicode[c - 128];
     return c;
 }

If ok, will try to merge it soon... thanks...

@geoffmcl geoffmcl added the Bug label Sep 22, 2020
@geoffmcl
Copy link
Contributor

Oops, I mean with Tidy comments ;=))

+    if (127 < c && c < 256) /* is. #891 */

That's better...

@ddkilzer
Copy link
Author

+    if (127 < c && c < 256) /* is. #891 */

Looks good to me. Thanks!

geoffmcl added a commit that referenced this issue Nov 30, 2020
@geoffmcl
Copy link
Contributor

20201130: @ddkilzer eventually done... thanks...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants