[bug report] Fix cg_read_strcmp()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello Jay Kamat,

This is a semi-automatic email about new static checker warnings.

The patch 48c2bb0b9cf8: "Fix cg_read_strcmp()" from Sep 7, 2018,
leads to the following Smatch complaint:

    ./tools/testing/selftests/cgroup/cgroup_util.c:111 cg_read_strcmp()
    error: we previously assumed 'expected' could be null (see line 97)

./tools/testing/selftests/cgroup/cgroup_util.c
    96		/* Handle the case of comparing against empty string */
    97		if (!expected)
                     ^^^^^^^^
Originally, we assumed that expected was non-NULL but we added a check
here.  I feel like maybe the intention was to check was supposed to be:

	if (expected[0] == '\0')

but that's just a random guess.

    98			size = 32;
    99		else
   100			size = strlen(expected) + 1;
   101	
   102		buf = malloc(size);
   103		if (!buf)
   104			return -1;
   105	
   106		if (cg_read(cgroup, control, buf, size)) {
   107			free(buf);
   108			return -1;
   109		}
   110	
   111		ret = strcmp(expected, buf);
                             ^^^^^^^^
Unchecked dereference.

   112		free(buf);
   113		return ret;

regards,
dan carpenter



[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux