Skip to content

Common state store discards case-only changes to opaque string values #3622

Description

@user01010111

At revision 59fad7a97cc67b35f2ae28b4228f92203c25c5d3, state_setinfo() compares the old and new values using strcasecmp(). A replacement that differs only in letter case is treated as unchanged, leaving the previous value stored.

A small check linked against the built common state library used:

st_tree_t *root = NULL;
int changed;
char *string_flags[] = { "STRING", "RW" };

state_setinfo(&root, "device.contact", "Operations");
state_setflags(root, "device.contact", 2, string_flags);
changed = state_setinfo(&root, "device.contact", "operations");
printf("changed=%d stored=%s\n",
    changed, state_getinfo(root, "device.contact"));
state_infofree(root);

Actual output:

changed=0 stored=Operations

Expected output:

changed=1 stored=operations

This matters for text values such as device.contact, documented as an opaque string. The MGE MIB mapping exposes that variable as a writable string. Case-only corrections to such values should survive publication.

Comparing stored values byte-for-byte would preserve these changes while leaving variable-name matching case-insensitive. Immutable-value behaviour should remain unchanged. Related PR #2549 concerns immutable-flag propagation and does not change this value comparison.

The result above comes from the shared state-library check with the variable marked STRING|RW. Controls for identical values, variable-name case matching, different mutable values and immutable values passed. No physical-device write was performed.

Investigated and drafted with assistance from OpenAI Codex (gpt-6-astra).

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

    AIFor good or bad, machine tools are upon us. Humans are still the responsible ones.C-strIssues and PRs about C/C++ methods, headers and data types dealing with strings and memory blocksIncorrect or missing readingsOn some devices driver-reported values are systemically off (e.g. x10, x0.1, const+Value, etc.)

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions