public inbox for linux-kernel-mentees@lists.linux-foundation.org
 help / color / mirror / Atom feed
* [PATCH] kconfig: replace strcpy() with strlcpy() in symbol.c
@ 2025-07-26 19:15 Suchit Karunakaran
  2025-07-26 20:38 ` kernel test robot
  0 siblings, 1 reply; 2+ messages in thread
From: Suchit Karunakaran @ 2025-07-26 19:15 UTC (permalink / raw)
  To: masahiroy, nicolas.schier, linux-kbuild
  Cc: skhan, linux-kernel-mentees, linux-kernel, Suchit Karunakaran

strcpy() performs no bounds checking and can lead to buffer overflows if
the input string exceeds the destination buffer size. This patch replaces
it with strlcpy(), which ensures the input is always NULL-terminated and
prevents overflows, following kernel coding guidelines.

Signed-off-by: Suchit Karunakaran <suchitkarunakaran@gmail.com>
---
 scripts/kconfig/symbol.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c
index 26ab10c0fd76..c44e8ac3e9fe 100644
--- a/scripts/kconfig/symbol.c
+++ b/scripts/kconfig/symbol.c
@@ -777,7 +777,7 @@ bool sym_set_string_value(struct symbol *sym, const char *newval)
 	else
 		return true;
 
-	strcpy(val, newval);
+	strlcpy(val, newval, size);
 	free((void *)oldval);
 	sym_clear_all_valid();
 
-- 
2.50.1


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

* Re: [PATCH] kconfig: replace strcpy() with strlcpy() in symbol.c
  2025-07-26 19:15 [PATCH] kconfig: replace strcpy() with strlcpy() in symbol.c Suchit Karunakaran
@ 2025-07-26 20:38 ` kernel test robot
  0 siblings, 0 replies; 2+ messages in thread
From: kernel test robot @ 2025-07-26 20:38 UTC (permalink / raw)
  To: Suchit Karunakaran, masahiroy, nicolas.schier, linux-kbuild
  Cc: oe-kbuild-all, skhan, linux-kernel-mentees, linux-kernel,
	Suchit Karunakaran

Hi Suchit,

kernel test robot noticed the following build errors:

[auto build test ERROR on masahiroy-kbuild/kbuild]
[also build test ERROR on linus/master v6.16-rc7 next-20250725]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Suchit-Karunakaran/kconfig-replace-strcpy-with-strlcpy-in-symbol-c/20250727-031729
base:   https://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild.git kbuild
patch link:    https://lore.kernel.org/r/20250726191515.171012-1-suchitkarunakaran%40gmail.com
patch subject: [PATCH] kconfig: replace strcpy() with strlcpy() in symbol.c
config: arc-randconfig-002-20250727 (attached as .config)
compiler: arc-linux-gcc (GCC) 8.5.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250727/202507270411.j9vfofzH-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202507270411.j9vfofzH-lkp@intel.com/

All error/warnings (new ones prefixed by >>):

   /usr/bin/ld: scripts/kconfig/symbol.o: in function `sym_set_string_value':
>> symbol.c:(.text+0x14cb): undefined reference to `strlcpy'
   collect2: error: ld returned 1 exit status
   make[3]: *** [scripts/Makefile.host:123: scripts/kconfig/conf] Error 1 shuffle=618416945
   make[3]: Target 'oldconfig' not remade because of errors.
   make[2]: *** [Makefile:735: oldconfig] Error 2 shuffle=618416945
   make[1]: *** [Makefile:248: __sub-make] Error 2 shuffle=618416945
   make[1]: Target 'oldconfig' not remade because of errors.
   make: *** [Makefile:248: __sub-make] Error 2 shuffle=618416945
   make: Target 'oldconfig' not remade because of errors.
--
   scripts/kconfig/symbol.c: In function 'sym_set_string_value':
>> scripts/kconfig/symbol.c:780:9: warning: implicit declaration of function 'strlcpy'; did you mean 'strncpy'? [-Wimplicit-function-declaration]
     780 |         strlcpy(val, newval, size);
         |         ^~~~~~~
         |         strncpy
   /usr/bin/ld: scripts/kconfig/symbol.o: in function `sym_set_string_value':
>> symbol.c:(.text+0x14cb): undefined reference to `strlcpy'
   collect2: error: ld returned 1 exit status
   make[3]: *** [scripts/Makefile.host:123: scripts/kconfig/conf] Error 1 shuffle=618416945
   make[3]: Target 'olddefconfig' not remade because of errors.
   make[2]: *** [Makefile:735: olddefconfig] Error 2 shuffle=618416945
   make[1]: *** [Makefile:248: __sub-make] Error 2 shuffle=618416945
   make[1]: Target 'olddefconfig' not remade because of errors.
   make: *** [Makefile:248: __sub-make] Error 2 shuffle=618416945
   make: Target 'olddefconfig' not remade because of errors.

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

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

end of thread, other threads:[~2025-07-26 20:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-26 19:15 [PATCH] kconfig: replace strcpy() with strlcpy() in symbol.c Suchit Karunakaran
2025-07-26 20:38 ` kernel test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox