linux-kbuild.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] kconfig/nconf: Replace strncpy() with snprintf()
@ 2025-06-12  7:48 Shankari Anand
  2025-06-12  7:48 ` Shankari Anand
  0 siblings, 1 reply; 3+ messages in thread
From: Shankari Anand @ 2025-06-12  7:48 UTC (permalink / raw)
  To: linux-kbuild, masahiroy; +Cc: Shankari Anand

I'm following up on my patch titled: [PATCH v2] kconfig/nconf: Replace strncpy() with snprintf() for safe string copy
Link: https://lore.kernel.org/linux-kbuild/CAPRMd3kWRHvUE=FuRoGBXYR1POCL05sec4-9u6_Pb667TBFaiA@mail.gmail.com/T/#t
I wanted to check whether this change is considered valid and applicable, or if there are any concerns about the direction or scope.

Why I have proposed this change -
1. item_add_str() in nconf.c: k_menu_items[index].str is a fixed-size char array. To copy the full string whilemaking sure it’s always null-terminated, snprintf() writes up to N-1 bytes + null terminator. strncpy() could leave the destination unterminated if tmp_str is too long which might be unsafe for new_item().
2. fill_window() in nconf.gui.c: The intent is to print at most len characters, clipped by the window width. Using snprintf() with precision (%.*s) ensures that we never read/write beyond bounds. With strncpy(), again, we risk lack of null termination unless manually handled (as it was done with tmp[len] = '\0';), which is brittle.
3. dialog_inputbox() in nconf.gui.c: result is a user-editable string buffer, pre-initialized with init. *result_len is the max buffer size. snprintf() will write up to result_len - 1 chars and null-terminate; strncpy() could fail to null-terminate if init is too long.

Thank you for your time and guidance.

Best regards,  
Shankari Anand (1):


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-06-24 11:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-12  7:48 [PATCH v2] kconfig/nconf: Replace strncpy() with snprintf() Shankari Anand
2025-06-12  7:48 ` Shankari Anand
2025-06-24 11:08   ` Masahiro Yamada

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).