-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Image causes integer overflow in docx export #6880
Comments
Sure enough, I get <wp:extent cx="5334000" cy="-269653970229347386159395778618353710042696546841345985910145121736599013708251444699062715983611304031680170819807090036488184653221624933739271145959211186566651840137298227914453329401869141179179624428127508653257226023513694322210869665811240855745025766026879447359920868907719574457253034494436336205824" /> |
relevant code (xpt,ypt) = desiredSizeInPoints opts attr
(either (const def) id (imageSize opts img))
-- 12700 emu = 1 pt
(xemu,yemu) = fitToPage (xpt * 12700, ypt * 12700)
(pageWidth * 12700) yemu is the thing that is overflowing. Trace reveals that |
I see the issue. Our |
JFIF header: typedef struct _JFIFHeader
{
BYTE SOI[2]; /* 00h Start of Image Marker */
BYTE APP0[2]; /* 02h Application Use Marker */
BYTE Length[2]; /* 04h Length of APP0 Field */
BYTE Identifier[5]; /* 06h "JFIF" (zero terminated) Id String */
BYTE Version[2]; /* 07h JFIF Format Revision */
BYTE Units; /* 09h Units used for Resolution */
BYTE Xdensity[2]; /* 0Ah Horizontal Resolution */
BYTE Ydensity[2]; /* 0Ch Vertical Resolution */
BYTE XThumbnail; /* 0Eh Horizontal Pixel Count */
BYTE YThumbnail; /* 0Fh Vertical Pixel Count */
} JFIFHEAD;
You can see in the first line the JFIF id string is |
The spec for JFIF says that x density and y density should always be nonzero, so I think this is a malformed jpg. |
👏 Rapid work! Thanks so much for looking into this! |
I've got an image that - for some reason - is causing an invalid
<wp: extent cy="...">
value. See attached image, input JSON (remember to update path to point to your image download location) and output docx.The resulting file fails to open in MS Word. Passing it through the Open XML SDK tool says that it has an error on
wp:extent cy
, saying it's "not a valid 'Int64' value". Indeed, inspection of this attribute shows that it's a very, very large negative number (potentially integer overflow?).Pandoc version
test.json
Command
bad.jpg
Output
out.docx
The text was updated successfully, but these errors were encountered: