building against OpENer as external library fails due to missing definitions

Open
#610 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
42/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Active
Tech stack
c, cmake

Research direction

Start with enipmessage.h and trace how PC_OPENER_ETHERNET_BUFFER_SIZE is supplied by the CMake files through add_definition() and OPENER_ETHERNET_BUFFER_SIZE. Check the installed public headers and libUtils usage when OpENer is consumed as an external library. Done means an external application can obtain the stack's buffer-size definition without guessing.

Written by the indexing model from the issue text.

Description

The declaration of type ENIPMessage in file enipmessage.h contains PC_OPENER_ETHERNET_BUFFER_SIZE as buffer size for the message buffer inside of that struct:

typedef struct enip_message {
  CipOctet message_buffer[PC_OPENER_ETHERNET_BUFFER_SIZE];
  CipOctet *current_message_position;
  size_t used_message_length;
} ENIPMessage;

It is part of libUtils and used by other parts of the stack. The file enipmessage.h is included by other headers and installed, so can be considered part of the public API of the stack. The value PC_OPENER_ETHERNET_BUFFER_SIZE however is not only referenced in that header but used in various places of the stack's code. It is passed as preprocessor option at build time of the stack and comes from the CMake files through an add_definition() statement which takes the CMake option OPENER_ETHERNET_BUFFER_SIZE as input.

This leads to the following situation: there is this build time option (OPENER_ETHERNET_BUFFER_SIZE) which results in hardcoded array sizes of the built stack. When later building against the stack as external library the same value is required as preprocessor definition but it's defined nowhere and you don't get it from public API headers. So it is essentially impossible to know its value at build time of an app. You need to guess.

An app using a different value for PC_OPENER_ETHERNET_BUFFER_SIZE as the stack used will probably crash?!

Dominant language
C
Stars
858
Forks
314
Avg merge
18d 2h
Merged PRs (30d)
1

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from EIPStackGroup/OpENer

All issues in EIPStackGroup/OpENer

Similar issues

More C issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.