Skip to content

harden: use bounded strlcpy/snprintf in example_app.c... - #411

Open
anupamme wants to merge 1 commit into
coolsnowwolf:openwrt-25.12from
anupamme:fix-repo-luci-c-lang-security-insecure-use-string-copy-fn-insecure-use-string-copy-fn-appli-df67d33e
Open

harden: use bounded strlcpy/snprintf in example_app.c...#411
anupamme wants to merge 1 commit into
coolsnowwolf:openwrt-25.12from
anupamme:fix-repo-luci-c-lang-security-insecure-use-string-copy-fn-insecure-use-string-copy-fn-appli-df67d33e

Conversation

@anupamme

Copy link
Copy Markdown

Summary

Harden input handling in applications/luci-app-oled/src/Example_Code/example_app.c (flagged by semgrep).

Vulnerability

Field Value
ID c.lang.security.insecure-use-string-copy-fn.insecure-use-string-copy-fn
Severity HIGH
Scanner semgrep
Rule c.lang.security.insecure-use-string-copy-fn.insecure-use-string-copy-fn
File applications/luci-app-oled/src/Example_Code/example_app.c:406
Assessment Defensive hardening

Description: Finding triggers whenever there is a strcpy or strncpy used. This is an issue because strcpy does not affirm the size of the destination array and strncpy will not automatically NULL-terminate strings. This can lead to buffer overflows, which can cause program crashes and potentially let an attacker inject code in the program. Fix this by using strcpy_s instead (although note that strcpy_s is an optional part of the C11 standard, and so may not be available).

Threat Model Context

This is a Node.js library - vulnerabilities affect downstream consumers who use this package.

Changes

  • applications/luci-app-oled/src/Example_Code/example_app.c

Note: The following lines in the same file use a similar pattern and may also need review: applications/luci-app-oled/src/Example_Code/example_app.c:261, applications/luci-app-oled/src/Example_Code/example_app.c:385, applications/luci-app-oled/src/Example_Code/example_app.c:392, applications/luci-app-oled/src/Example_Code/example_app.c:417, applications/luci-app-oled/src/Example_Code/example_app.c:423 (and 20 more)

Behavior Preservation

The change is scoped to 1 file on the vulnerable path; it only tightens handling of untrusted input and leaves valid inputs unaffected.


This patch removes an exploit primitive — a code pattern that, while not independently exploitable today, could be chained with other weaknesses by automated exploit-development tooling. Proactive removal of such primitives raises the bar against increasingly capable automated attack tools.


Automated security fix by OrbisAI Security

Finding triggers whenever there is a strcpy or strncpy used
Addresses c.lang.security.insecure-use-string-copy-fn.insecure-use-string-copy-fn

Signed-off-by: anupamme <mediratta@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant