mdsplus icon indicating copy to clipboard operation
mdsplus copied to clipboard

mdsplus8 has wrong node name sizes in tcl_directory.c

Open mwinkel-dev opened this issue 1 year ago • 1 comments

Affiliation MIT PSFC

Version(s) Affected mdsplus8

Platform Ubuntu 20

Describe the bug MDSplus version 8 supports long node names of up to 63 visible characters plus one trailing null character. Some references in the source code incorrectly use 64 when they should instead use 63.

To Reproduce Steps to reproduce the behavior:

  1. Examine the current Alpha's source code for tcl_directory.c and note the pattern used for version 7.x's node names that can have up to 12 visible characters.
  2. Compare that pattern with that used in the mdsplus8 branch for tcl_directory.c.

Expected behavior n/a

Screenshots n/a

Additional context n/a

mwinkel-dev avatar Dec 19 '23 23:12 mwinkel-dev

The Version 7 (and earlier) pattern does not apply to Version 8, because of an important difference in the node name definitions.

  • Version 8 defines a node name to be a 64 character array that always includes a null char terminator (thus a maximum of 63 visible characters).
  • Pre-v8 defined a node name as an array of 12 visible characters and an optional null terminator. Meaning that node name, A234567890B2, was stored without a trailing null. Shorter node names, such as XYZ, were stored with null characters filling the rest of the node name array.

The optional null character in v7 and earlier, added some complexity to all code that processes node names. Reading used strncpy() to obtain the 12 characters from the node name field, and then appended a null terminator if needed. Thus the v7 code needs to be adjusted a bit for v8 which always has a null terminator.

A spot check of various portions of the v8 source code reveals that there are some places where the adjustments have not yet been made. Or that the adjustments were done slightly incorrectly. This typically results in an "off by one" error in the string length (e.g., dropping the 63rd visible character of a long node name).

mwinkel-dev avatar Dec 20 '23 19:12 mwinkel-dev