[procps] Re: some more master & newlib stuff

  • From: Craig Small <csmall@xxxxxxxxxx>
  • To: Procps-ng Mail list <procps@xxxxxxxxxxxxx>
  • Date: Wed, 20 Dec 2017 10:36:48 +0000

On Sat, 2 Dec 2017 at 06:19 Jim Warner <james.warner@xxxxxxxxxxx> wrote:

Attached are 2 replacement tarballs, one for each branch.

They are now both committed. No need to rebase as they are patches not pull
requests.

The 4 ones for master, there wasn't any issue.

For the newlib ones, the alloc removal stuff was quite interesting. Never
really sure why it was there myself but glad to see it gone.
Patch 5, where you have changed the return calls I think the objectives
need to go somewhere easier to remember, perhaps on the procps wiki page so
people understand what the return values mean.  For individual functions
the documentation should explain it but the objectives are broader.

Finally, with harden flags enabled, I got this warning:
proc/readproc.c: In function ‘simple_nexttid’:
proc/readproc.c:1185:46: warning: ‘%s’ directive output may be truncated
writing up to 255 bytes into a region of size between 41 and 51
[-Wformat-truncation=]
   snprintf(path, PROCPATHLEN, "/proc/%d/task/%s", p->tgid, ent->d_name);
                                              ^~
proc/readproc.c:1185:3: note: ‘snprintf’ output between 14 and 279 bytes
into a destination of size 64
   snprintf(path, PROCPATHLEN, "/proc/%d/task/%s", p->tgid, ent->d_name);
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

I think it is saying, look you have 64 bytes for the destination string,
the integer and the static template bytes means you have 41-51 bytes left,
but d_name can be 255 characters long, which won't fit.

But we know this won't happen, because in the task directory d_name is a
string representation of an integer, so is a maximum of 10 (I think)
characters long. Much less than 41 anyhow.
Changing %s to %.10s fixes this as it is now explicitly only 10 characters
long.

 - Craig


--
Craig Small             https://dropbear.xyz/     csmall at : enc.com.au
Debian GNU/Linux        https://www.debian.org/   csmall at : debian.org
Mastodon: @smallsees@xxxxxxxxxxxxxxxxxxx             Twitter: @smallsees
GPG fingerprint:      5D2F B320 B825 D939 04D2  0519 3938 F96B DF50 FEA5

Other related posts: