question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Jpx infinite loop for tiles with 0 Psot

See original GitHub issue

JPEG2000 allows to set tile-part length to 0 in SOT segment (only the last part). This case is not handled in the code resulting in an infinite loop. End of data stream is marked by EOC in this case. As padding is possible, it must be found. Below possible solution:

tile.length = readUint32(data, position + 4);
if (tile.length === 0) {
  for (var i = end - 2; i > position + length; i--) {
    if (0xFFD9 === readUint16(data, i)) {
      tile.dataEnd = i;
      break;
    }
  }
  if (tile.dataEnd === undefined) {
    throw new Error('JPX Error: missing EOC');
  }
} else {
  tile.dataEnd = tile.length + position - 2;
}

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8

github_iconTop GitHub Comments

1reaction
Snuffleupaguscommented, May 9, 2019

@timvandermeij Sorry, but I think the right label would be 4-image-jpx here.


Also, the document in https://github.com/mozilla/pdf.js/issues/10793#issuecomment-490522099 doesn’t contain a single JPX image, actually it doesn’t even contain any XObject of any kind. Hence that comment is completely unrelated to this issue, and only serves to add confusion to the discussion. (It seems related to a custom implementation, since the file renders fine in the default viewer.)

@timvandermeij Mind hiding/removing https://github.com/mozilla/pdf.js/issues/10793#issuecomment-490522099 and also this comment itself; thank you!

0reactions
madejcommented, Feb 20, 2021

On the other hand solution is right there, just review it and add it to codebase.

As purely a matter of principle, we don’t want to make these types of code changes without any way of either verifying or testing them since doing so has the potential to cause regressions elsewhere.

If you look closer, it’s just an ‘if’ statement for this special case, ‘else’ doesn’t change anything

Creating j2k file seems quite easy with hex editor.

If it’s indeed easy, then please just provide a PDF file that can be used to reproduce this 😃

I said j2k.

Without more information, I’d still suggest closing this issue as INCOMPLETE for now.

It’s closed by now. 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

Version history — Bio-Formats 5.6.0 documentation
prevented a potential infinite loop when a scene with a pyramid is missing. cellSens VSI. a new option has been added to throw...
Read more >
[gs-commits] ghostpdl annotated tag, ghostpdl-9.18rc1, created ...
Bug 692263 spot and elide glyphs with zero dimensions. Bug 689546: Add clist.dev to the ... Fix bug #692246 infinite loop searching the...
Read more >
Detected Vulnerabilities and Situations in sgpkg-ips-1520-5242
This update package contains. Fingerprint signatures, 13439. Vulnerabilities, 8939. CVE/CAN entries, 7133. Applications, 7382.
Read more >
Detailed History of Ghostscript versions 8.n - hdlbrokerdux.com.ar - /
The code now initialises the member of the structure to 0, which we then ... in a single string pdfwrite would enter an...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found