Skip to content

Fix Potential Buffer Overflow#92

Open
Lightning11wins wants to merge 1 commit into
masterfrom
fixes
Open

Fix Potential Buffer Overflow#92
Lightning11wins wants to merge 1 commit into
masterfrom
fixes

Conversation

@Lightning11wins
Copy link
Copy Markdown
Contributor

@Lightning11wins Lightning11wins commented Mar 11, 2026

Fix a potential buffer overflow in wgtr.c.

@Lightning11wins Lightning11wins added bug ai-review Request AI review for PRs. labels Mar 11, 2026
@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented Mar 11, 2026

Greptile Summary

This PR fixes a copy-paste error in wgtrNewNode where strtcpy(node->Type, type, sizeof(node->Name)) used the size of Name instead of Type as the buffer bound. Both WgtrNode.Type and WgtrNode.Name are currently char[64], so no overflow was occurring, but the fix correctly aligns the size argument with the destination field, guarding against any future struct layout changes.

Confidence Score: 5/5

This PR is safe to merge — it is a minimal, correct bug fix with no adverse side effects.

Single-line change correcting the wrong sizeof argument in a strtcpy call. Both fields are currently the same size (char[64]), so there is no existing overflow; the fix removes a latent hazard and improves correctness. No new logic, no regressions, no security concerns.

No files require special attention.

Important Files Changed

Filename Overview
centrallix/wgtr/wgtr.c Single-line fix: corrects sizeof(node->Name)sizeof(node->Type) in strtcpy call for node->Type. Both fields happen to be char[64], so no real overflow was occurring, but the fix removes a latent risk if field sizes ever diverge.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["wgtrNewNode(name, type, ...)"] --> B["nmMalloc / memset / SETMAGIC"]
    B --> C["strtcpy(node->Name, name, sizeof(node->Name))"]
    C --> D["strtcpy(node->Type, type, sizeof(node->Type))\n✅ fixed (was sizeof(node->Name))"]
    D --> E["snprintf(node->DName, ...)"]
    E --> F["Set geometry & other fields"]
    F --> G["Return pWgtrNode"]
Loading

Reviews (2): Last reviewed commit: "Fix a potential buffer overflow bug." | Re-trigger Greptile

@Lightning11wins
Copy link
Copy Markdown
Contributor Author

Lightning11wins commented Mar 12, 2026

PR cleared for human review.

@Lightning11wins Lightning11wins added the size: trivial Easy to review, probably ~100 lines or fewer. label Apr 27, 2026
@Lightning11wins Lightning11wins changed the title General Fixes Potential Buffer Overflow Fix May 7, 2026
@Lightning11wins
Copy link
Copy Markdown
Contributor Author

Redefining the scope on this since I've changed my methodology and no longer think trying to cluster unrelated fixes into a single PR is a good idea.

@Lightning11wins
Copy link
Copy Markdown
Contributor Author

Once again, this PR is still cleared for human review.

@Lightning11wins Lightning11wins changed the title Potential Buffer Overflow Fix Fix Potential Buffer Overflow May 7, 2026
@Lightning11wins Lightning11wins self-assigned this May 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-review Request AI review for PRs. bug size: trivial Easy to review, probably ~100 lines or fewer.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant