Merge from OpenBSD:

>sprintf -> snprintf paranoia

Obtainted from: OpenBSD src/bin/stty/print.c v1.5
	by Todd Miller <millert@openbsd.org>
This commit is contained in:
eivind 1997-12-12 18:11:29 +00:00
parent 3c856a893d
commit a208e260b6

View File

@ -30,7 +30,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* $Id$ * $Id: print.c,v 1.8 1997/02/22 14:05:53 peter Exp $
*/ */
#ifndef lint #ifndef lint
@ -205,8 +205,10 @@ print(tp, wp, ldisc, fmt)
if (fmt != BSD && cc[p->sub] == p->def) if (fmt != BSD && cc[p->sub] == p->def)
continue; continue;
#define WD "%-8s" #define WD "%-8s"
(void)sprintf(buf1 + cnt * 8, WD, p->name); (void)snprintf(buf1 + cnt * 8, sizeof(buf1) - cnt * 8,
(void)sprintf(buf2 + cnt * 8, WD, ccval(p, cc[p->sub])); WD, p->name);
(void)snprintf(buf2 + cnt * 8, sizeof(buf2) - cnt * 8,
WD, ccval(p, cc[p->sub]));
if (++cnt == LINELENGTH / 8) { if (++cnt == LINELENGTH / 8) {
cnt = 0; cnt = 0;
(void)printf("%s\n", buf1); (void)printf("%s\n", buf1);