Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/telnet switch sprintf to snprintf in places.



details:   https://anonhg.NetBSD.org/src/rev/0473fdaf1cb5
branches:  trunk
changeset: 995232:0473fdaf1cb5
user:      maya <maya%NetBSD.org@localhost>
date:      Wed Dec 12 19:05:32 2018 +0000

description:
switch sprintf to snprintf in places.

Reported by hacker fantastic, thanks!

ok xtos.

diffstat:

 usr.bin/telnet/telnet.c    |  16 ++++++++--------
 usr.bin/telnet/utilities.c |   6 +++---
 2 files changed, 11 insertions(+), 11 deletions(-)

diffs (78 lines):

diff -r d8ca5bc52112 -r 0473fdaf1cb5 usr.bin/telnet/telnet.c
--- a/usr.bin/telnet/telnet.c   Wed Dec 12 18:11:00 2018 +0000
+++ b/usr.bin/telnet/telnet.c   Wed Dec 12 19:05:32 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: telnet.c,v 1.36 2012/01/10 13:49:32 christos Exp $     */
+/*     $NetBSD: telnet.c,v 1.37 2018/12/12 19:05:32 maya Exp $ */
 
 /*
  * Copyright (c) 1988, 1990, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)telnet.c   8.4 (Berkeley) 5/30/95";
 #else
-__RCSID("$NetBSD: telnet.c,v 1.36 2012/01/10 13:49:32 christos Exp $");
+__RCSID("$NetBSD: telnet.c,v 1.37 2018/12/12 19:05:32 maya Exp $");
 #endif
 #endif /* not lint */
 
@@ -856,8 +856,8 @@
            name = gettermname();
            len = strlen(name) + 4 + 2;
            if (len < NETROOM()) {
-               sprintf((char *)temp, "%c%c%c%c%s%c%c", IAC, SB, TELOPT_TTYPE,
-                               TELQUAL_IS, name, IAC, SE);
+               snprintf((char *)temp, sizeof(temp), "%c%c%c%c%s%c%c", IAC, SB,
+                               TELOPT_TTYPE, TELQUAL_IS, name, IAC, SE);
                ring_supply_data(&netoring, temp, len);
                printsub('>', &temp[2], len-2);
            } else {
@@ -878,8 +878,8 @@
 
            TerminalSpeeds(&isp, &osp);
 
-           sprintf((char *)temp, "%c%c%c%c%ld,%ld%c%c", IAC, SB, TELOPT_TSPEED,
-                   TELQUAL_IS, osp, isp, IAC, SE);
+           snprintf((char *)temp, sizeof(temp), "%c%c%c%c%ld,%ld%c%c", IAC, SB,
+                   TELOPT_TSPEED, TELQUAL_IS, osp, isp, IAC, SE);
            len = strlen((char *)temp+4) + 4;   /* temp[3] is 0 ... */
 
            if (len < NETROOM()) {
@@ -983,8 +983,8 @@
                send_wont(TELOPT_XDISPLOC, 1);
                break;
            }
-           sprintf((char *)temp, "%c%c%c%c%s%c%c", IAC, SB, TELOPT_XDISPLOC,
-                   TELQUAL_IS, dp, IAC, SE);
+           snprintf((char *)temp, sizeof(temp), "%c%c%c%c%s%c%c", IAC, SB,
+                   TELOPT_XDISPLOC, TELQUAL_IS, dp, IAC, SE);
            len = strlen((char *)temp+4) + 4;   /* temp[3] is 0 ... */
 
            if (len < NETROOM()) {
diff -r d8ca5bc52112 -r 0473fdaf1cb5 usr.bin/telnet/utilities.c
--- a/usr.bin/telnet/utilities.c        Wed Dec 12 18:11:00 2018 +0000
+++ b/usr.bin/telnet/utilities.c        Wed Dec 12 19:05:32 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: utilities.c,v 1.23 2012/01/09 16:08:55 christos Exp $  */
+/*     $NetBSD: utilities.c,v 1.24 2018/12/12 19:05:32 maya Exp $      */
 
 /*
  * Copyright (c) 1988, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)utilities.c        8.3 (Berkeley) 5/30/95";
 #else
-__RCSID("$NetBSD: utilities.c,v 1.23 2012/01/09 16:08:55 christos Exp $");
+__RCSID("$NetBSD: utilities.c,v 1.24 2018/12/12 19:05:32 maya Exp $");
 #endif
 #endif /* not lint */
 
@@ -633,7 +633,7 @@
                }
                {
                    char tbuf[64];
-                   sprintf(tbuf, "%s%s%s%s%s",
+                   snprintf(tbuf, sizeof(tbuf), "%s%s%s%s%s",
                        pointer[2]&MODE_EDIT ? "|EDIT" : "",
                        pointer[2]&MODE_TRAPSIG ? "|TRAPSIG" : "",
                        pointer[2]&MODE_SOFT_TAB ? "|SOFT_TAB" : "",



Home | Main Index | Thread Index | Old Index