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

add a conditional statement to avoid fread size too big to coredump #63

Closed
wants to merge 1 commit into from

Conversation

attackoncs
Copy link

The function ttfLoadHDMX uses the parsed hdmx size to allocate a Width heap buffer, copies content from the file, and the copy size is determined by numGlyphs. There is no validation of the actual memory size before storing it. Due to the controllable content and size, this could potentially lead to a heap overflow and result in arbitrary code execution.

Signed-off-by: attackoncs <2710651793@qq.com>
@kberry
Copy link
Collaborator

kberry commented Jan 21, 2024

Well, since you didn't answer my email, I made the fix of allocating the number of entries needed in the first place, namely numGlyphs+1. (r69520 upstream)

BTW, I don't understand why this is numGlyphs+1 and not numGlyphs, per https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6hdmx.html, but since the program has always read numGlyphs+1, just leaving it that way.

If you have an actual font that triggers the bug, please let me know. Thanks.

--- libttf/hdmx.c       (revision 69517)
+++ libttf/hdmx.c       (working copy)
@@ -43,7 +43,7 @@ static void ttfLoadHDMX (FILE *fp,HDMXPtr hdmx,ULO
        {
            hdmx->Records[i].PixelSize = ttfGetBYTE(fp);
            hdmx->Records[i].MaxWidth = ttfGetBYTE(fp);
-           hdmx->Records[i].Width = XCALLOC (hdmx->size, BYTE);
+           hdmx->Records[i].Width = XCALLOC (hdmx->numGlyphs+1, BYTE);
            fread ((hdmx->Records+i)->Width, sizeof(BYTE), hdmx->numGlyphs+1,fp);
        }
 }

@kberry kberry closed this Jan 21, 2024
norbusan pushed a commit that referenced this pull request Jan 21, 2024
git-svn-id: svn://tug.org/texlive/trunk/Build/source@69520 c570f23f-e606-0410-a88d-b1316a301751
t-tk pushed a commit to texjporg/tex-jp-build that referenced this pull request Jan 28, 2024
git-svn-id: svn://tug.org/texlive/trunk/Build@69520 c570f23f-e606-0410-a88d-b1316a301751
@vadimkantorov
Copy link

Sorry for abusing this PR's comment section to contact the maintainers of this mirror

mktexlsr.pl script is missing from https://github.com/TeX-Live/texlive-source/tree/trunk/texk/texlive/linked_scripts/texlive - there is available older shell script mktexlsr, but mktexlsr.pl is required in fmtutil.pl

It would be great to also put it under the version-control and mirror in Git.

@kberry
Copy link
Collaborator

kberry commented Feb 7, 2024

I added mktexlsr.pl to linked_scripts. Thanks.

@vadimkantorov
Copy link

Please consider adding a Discussions section (or even Issues) section for this repo :), although I understand that it might be better to not open them if there are not enough people for answering these...

I made some successful efforts of writing TexLive makefiles for building and compiling to WebAssembly which might be interesting to upstream and adding to CI (at least, adding full build scripts to GitHub Actions would be nice, and GH CI is free and allows various Linuxes, Windows and some Mac - this is helpful for more reproducible builds and helping users to start contributing): https://tug.org/pipermail/tlbuild/2021q1/004806.html (some of issues from this email are solved, but some are still standing). Me and my friend are also making some efforts towards fully cross-platform Tex programs. We would be happy to be in contact with someone from the TexLive / Tex ecosystem to discuss these efforts and potentially upstreaming them :)

@norbusan
Copy link
Member

norbusan commented Feb 8, 2024

@vadimkantorov Thanks for your comments, but please consider that this repo here is NOTHING BUT A MIRROR of the real one that is in SVN. It is here only because we want to do CI testing and release building, but it contains only a small part (the source part) of TeX Live. The full git mirror is 50+Gb which is not allowed by Github, bu you can look at https://git.texlive.info/

Discussion about bugs, builds, suggestions etc should happen on the main texlive mailing list, or on the dedicated tlbuild mailing list.

I am more than happy to get input from you about further CI build integrations. I have recently updated our CI builds to more architectures. I am more than happy to discuss/integrate more test!

@kberry
Copy link
Collaborator

kberry commented Feb 8, 2024

Just to emphasize what Norbert said: The mailing lists are the place for discussion. In your case, probably tlbuild@tug.org related to building specifically, although the general tex-live@tug.org is also fine.

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

Successfully merging this pull request may close these issues.

None yet

4 participants