Skip to content

General Fixes#92

Open
Lightning11wins wants to merge 1 commit intomasterfrom
fixes
Open

General Fixes#92
Lightning11wins wants to merge 1 commit intomasterfrom
fixes

Conversation

@Lightning11wins
Copy link
Contributor

Fix bugs I came across that don't fit into any other PRs. Should be very easy to review.

Current fixes:

  • A potential buffer overflow in wgtr.c.

@Lightning11wins Lightning11wins added bug ai-review Request AI review of this PR labels Mar 11, 2026
@greptile-apps
Copy link

greptile-apps bot commented Mar 11, 2026

Greptile Summary

This PR corrects a latent sizeof mismatch in wgtrNewNode (wgtr.c): the strtcpy call that copies into node->Type was incorrectly using sizeof(node->Name) as its size limit instead of sizeof(node->Type).

  • Fix: strtcpy(node->Type, type, sizeof(node->Name))strtcpy(node->Type, type, sizeof(node->Type))
  • Impact today: In the current WgtrNode struct both Type and Name are declared as char[64], so the incorrect sizeof returned the same value and no overflow occurred at runtime. However, the fix is still important for correctness and future-proofing — if the sizes of the two fields ever diverge, the original code would silently under-constrain the write into Type.
  • No other logic changes were made; the rest of wgtrNewNode is untouched.

Confidence Score: 5/5

  • This PR is safe to merge — it is a single-line correctness fix with no functional side effects in the current codebase.
  • The change is minimal (one character sequence: NameType inside a sizeof), semantically correct, and the surrounding code is straightforward. Both fields are currently the same size so there is no behavioural difference today, only an improvement in correctness and resilience to future struct changes.
  • No files require special attention.

Important Files Changed

Filename Overview
centrallix/wgtr/wgtr.c Single-line correctness fix: strtcpy for node->Type now uses sizeof(node->Type) instead of sizeof(node->Name). Both fields are currently 64 bytes in WgtrNode, so no actual overflow existed, but the fix correctly ties the size guard to the destination buffer and prevents latent risk if field sizes ever diverge.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[wgtrNewNode called\nname, type, geometry args] --> B{nmMalloc succeeds?}
    B -- No --> C[mssError + return NULL]
    B -- Yes --> D[memset node to 0\nSETMAGIC]
    D --> E[strtcpy node->Name, name,\nsizeof node->Name]
    E --> F["strtcpy node->Type, type,\nsizeof(node->Type)\n✅ FIXED: was sizeof(node->Name)"]
    F --> G[snprintf node->DName\nwith SerialID]
    G --> H[Set geometry fields\nr_x r_y width height etc.]
    H --> I[xaInit Properties\nChildren Interfaces]
    I --> J[return node]
Loading

Last reviewed commit: 67d2a4b

@Lightning11wins
Copy link
Contributor Author

PR cleared for human review.

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

Labels

ai-review Request AI review of this PR bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant