Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • VTK VTK
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 829
    • Issues 829
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 239
    • Merge requests 239
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • VTKVTK
  • VTKVTK
  • Issues
  • #17978
Closed
Open
Issue created Aug 14, 2020 by Patrick Conrad@patrick.conrad

Incorrect error handling in vtkSocket::Connect

I ran into paraview/paraview#17752 (closed) and discovered a bug in vtkSocket::Connect. That ticket created a condition where it tried to connect to an invalid hostname (specifically, the hostname of the machine, which was not present in /etc/hosts on OSX).

The function vtkSocket::Connect executes as follows. Assume the hostName= “some_invalid_hostname”:

  • gethostbyname fails to look up the hostname, https://gitlab.kitware.com/vtk/vtk/-/blob/master/Common/System/vtkSocket.cxx#L395
  • Then it uses inet_addr to try to convert a XXX.XXX.XXX.XXX string, which (obviously) fails, and returns -1. It doesn't detect this error condition, but since this is a perfectly valid address, gethostbyaddr converts it to 255.255.255.255.

Then it tries to connect to the broadcast address instead of flagging the unresolvable hostname. Since it didn't set the options correctly for a broadcast address, it throws EACCES, resulting in the error I saw.

Man page indicates a possible resolution (https://man7.org/linux/man-pages/man3/inet_addr.3.html):

The inet_addr() function converts the Internet host address cp from IPv4 numbers-and-dots notation into binary data in network byte order. If the input is invalid, INADDR_NONE (usually -1) is returned. Use of this function is problematic because -1 is a valid address (255.255.255.255). Avoid its use in favor of inet_aton(), inet_pton(3), or getaddrinfo(3), which provide a cleaner way to indicate error return.

Assignee
Assign to
Time tracking