<html>
    <head>
      <base href="https://bugs.freedesktop.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - I/O errors during checkheader() cause hang"
   href="https://bugs.freedesktop.org/show_bug.cgi?id=104502">104502</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>I/O errors during checkheader() cause hang
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>poppler
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux (All)
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>minor
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>medium
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>general
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>poppler-bugs@lists.freedesktop.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>btimby@gmail.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=136569" name="attach_136569" title="Check return code of getChar(), abort reading on error.">attachment 136569</a> <a href="attachment.cgi?id=136569&action=edit" title="Check return code of getChar(), abort reading on error.">[details]</a></span> <a href='page.cgi?id=splinter.html&bug=104502&attachment=136569'>[review]</a>
Check return code of getChar(), abort reading on error.

Hi, I ran into an issue when using pdftotext on files stored on a CIFS mount. A
problem with the CIFS server was causing EIO to be returned for read() calls.
It takes about 1 minute for EIO to be returned, blocking each read() for about
1 minute before it fails.

This caused pdftotext to run for around 16 hours before finally failing. I
tracked this down to PDFDoc::checkHeader(), which attempts to read 1024 chars
using FileStream::getChar() into a buffer. It uses this buffer for file type
detection.

The problem is that it does not check the return code of getChar(). getChar()
returns EOF in response to the EIO, but that EOF is just placed into the
buffer, and another read() is attempted (1024 times) making the process block
in uninterruptible sleep for 16 hours or so.

The fix is to check this return code and stop reading. I am attaching a patch.</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>