mirror of
git://sourceware.org/git/newlib-cygwin.git
synced 2025-01-22 23:17:28 +08:00
b0fc9f23b5
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>
THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. Cygwin documentation is available on the net at https://cygwin.com You might especially be interested in https://cygwin.com/faq/faq.html#faq.programming.building-cygwin