]> sourceware.org Git - newlib-cygwin.git/commit
Cygwin: ps: fix compiler warning in ttynam
authorCorinna Vinschen <corinna@vinschen.de>
Wed, 26 Feb 2020 20:08:51 +0000 (21:08 +0100)
committerCorinna Vinschen <corinna@vinschen.de>
Wed, 26 Feb 2020 20:08:51 +0000 (21:08 +0100)
commit09981903e6d3a42a23b13cfaed3c9b8b0f0e2f02
tree3c84f3525748654cac1bbf04f3ebfed97ade9af1
parent0a37e9f0bc24c6d326816e6686c4eaa25b4fd83e
Cygwin: ps: fix compiler warning in ttynam

The helper function ttynam creates a tty name by using sprintf wrongly
on a pretty short buffer.  The foramt string only specifies a minimum
field length, not a maximum field length, so gcc-9.2.0 complains:

  ps.cc:101:23: warning: 'sprintf' may write a terminating nul past the
  end of the destination [-Wformat-overflow=]

Fix this thoroughly by specifying a maximum field width as well as by
using snprintf with a fixed buffer length.  Also, drop using a static
buffer in favor of using a buffer in the caller.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
winsup/utils/ps.cc
This page took 0.032579 seconds and 5 git commands to generate.