Uploaded image for project: 'MariaDB Connector/node.js'
  1. MariaDB Connector/node.js
  2. CONJS-79

Read errors while processing LOCAL INFILE causes process crash



    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • None
    • 2.1.0
    • other
    • None


      The code that handles read LOCAL INFILE files does not have an error event handler on the readable stream for the file. If there's a read error while reading the file then the node process will crash as that's the default behavior for event emitter without error handlers.

      There's also a race condition between checking for read access and actually opening the file for reading. If the permissions of the file change in between then the read stream will error out.

      I put together a dummy test to simulate this behavior by mocking the fs.createReadStream(...) to replace the requested file with a non-existent one so that the access check passes but the read fails. As expected the node process crashes. (See https://travis-ci.org/sehrope/mariadb-connector-nodejs/jobs/537201949#L1232-L1322 for test results of this)

      It's likely nobody ran into this till now as the access check / read pattern would work in most situations (it's a rare race condition) and unless a hardware disk I/O error occurs the overall read action will succeed as well.

      Adding an error handler to the read stream should handle the file not existing, not being accessible to the current process, and any read errors that happen along the way.




            diego dupin Diego Dupin
            sehrope Sehrope Sarkuni
            0 Vote for this issue
            2 Start watching this issue



              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.