lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <202412210924.TRBZsDii-lkp@intel.com>
Date: Sat, 21 Dec 2024 09:21:49 +0800
From: kernel test robot <lkp@...el.com>
To: Jacek Anaszewski <jacek.anaszewski@...il.com>
Cc: oe-kbuild-all@...ts.linux.dev, linux-kernel@...r.kernel.org,
	Linus Walleij <linus.walleij@...aro.org>
Subject: drivers/leds/led-core.c:461:78: warning: 'snprintf' output may be
 truncated before the last format character

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   499551201b5f4fd3c0618a3e95e3d0d15ea18f31
commit: bb4e9af0348dfeafd66c7e7f82e8a0983fe5390c leds: core: Add support for composing LED class device names
date:   5 years ago
config: x86_64-randconfig-077-20241209 (https://download.01.org/0day-ci/archive/20241221/202412210924.TRBZsDii-lkp@intel.com/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241221/202412210924.TRBZsDii-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@...el.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202412210924.TRBZsDii-lkp@intel.com/

All warnings (new ones prefixed by >>):

   drivers/leds/led-core.c: In function 'led_compose_name':
>> drivers/leds/led-core.c:461:78: warning: 'snprintf' output may be truncated before the last format character [-Wformat-truncation=]
     461 |                         snprintf(led_classdev_name, LED_MAX_NAME_SIZE, "%s:%s",
         |                                                                              ^
   drivers/leds/led-core.c:461:25: note: 'snprintf' output 2 or more bytes (assuming 65) into a destination of size 64
     461 |                         snprintf(led_classdev_name, LED_MAX_NAME_SIZE, "%s:%s",
         |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     462 |                                  devicename, tmp_buf);
         |                                  ~~~~~~~~~~~~~~~~~~~~


vim +/snprintf +461 drivers/leds/led-core.c

   421	
   422	int led_compose_name(struct device *dev, struct led_init_data *init_data,
   423			     char *led_classdev_name)
   424	{
   425		struct led_properties props = {};
   426		struct fwnode_handle *fwnode = init_data->fwnode;
   427		const char *devicename = init_data->devicename;
   428	
   429		if (!led_classdev_name)
   430			return -EINVAL;
   431	
   432		led_parse_fwnode_props(dev, fwnode, &props);
   433	
   434		if (props.label) {
   435			/*
   436			 * If init_data.devicename is NULL, then it indicates that
   437			 * DT label should be used as-is for LED class device name.
   438			 * Otherwise the label is prepended with devicename to compose
   439			 * the final LED class device name.
   440			 */
   441			if (!devicename) {
   442				strscpy(led_classdev_name, props.label,
   443					LED_MAX_NAME_SIZE);
   444			} else {
   445				snprintf(led_classdev_name, LED_MAX_NAME_SIZE, "%s:%s",
   446					 devicename, props.label);
   447			}
   448		} else if (props.function || props.color_present) {
   449			char tmp_buf[LED_MAX_NAME_SIZE];
   450	
   451			if (props.func_enum_present) {
   452				snprintf(tmp_buf, LED_MAX_NAME_SIZE, "%s:%s-%d",
   453					 props.color_present ? led_colors[props.color] : "",
   454					 props.function ?: "", props.func_enum);
   455			} else {
   456				snprintf(tmp_buf, LED_MAX_NAME_SIZE, "%s:%s",
   457					 props.color_present ? led_colors[props.color] : "",
   458					 props.function ?: "");
   459			}
   460			if (init_data->devname_mandatory) {
 > 461				snprintf(led_classdev_name, LED_MAX_NAME_SIZE, "%s:%s",

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ