Skip to content

Two different symbol entries with the same name cause "plc show-symbols" to fail with an error "Corrupt nameLength" #308

Description

@hanak

For reason unknown to me, ADS server reported two ADS symbols of the same name. And, adstool responded with an error "Corrupt nameLegth".

The behavior (of the adstool) is caused by an assumption that a name is unique in SymbolAccess::FetchSymbolEntries():

		const auto next = entries.insert(bhf::ads::SymbolEntry::Parse(
							 data, bytesRead))
					  .first->second;

Since std::map::insert will insert a record only if its key is not in yet (https://en.cppreference.com/cpp/container/map/insert), this leaves the previously inserted symbol entry untouched. As a consequence, the routine moves data using the entry length of the previous inserted symbol entry resulting into a failure.

I would expect that FetchSymbolEntries() reports there is a duplicate and either pick one of them or fails. In either case, I would expect it to avoid using the entry length of a different record to access memory.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions