Skip to content
  • Rob Swindell's avatar
    Fix getnodedat() error handling and usage · e7642321
    Rob Swindell authored
    If a file descriptor is passed to getnodedat() and the lock retry counter was
    reached, the file would be closed, but the passed file descriptor reference
    would not be set to -1. This could result in exceptions (from subsequent read
    attempts on the referenced file descriptor) in cases where the node.dab could
    not be locked or read by getnodedat() and was thus closed.
    The set/get_node_* helper functions (used by MQTT) were not initializing the
    node.dab file descriptor (i.e. to -1), so it's possible getnodedat() could
    try to read from and close an invalid/wrong open file descriptor. If the local
    variable happened to be initialized to a value <= 0, then, no problem, but
    this is undefined behavior (UB).