Source-Changes-HG archive

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

[src/trunk]: src/lib/libtelnet use bounded string op



details:   https://anonhg.NetBSD.org/src/rev/359e8a6681a9
branches:  trunk
changeset: 549503:359e8a6681a9
user:      itojun <itojun%NetBSD.org@localhost>
date:      Tue Jul 15 05:09:34 2003 +0000

description:
use bounded string op

diffstat:

 lib/libtelnet/auth.c       |   6 +++---
 lib/libtelnet/enc_des.c    |  14 +++++++-------
 lib/libtelnet/encrypt.c    |   6 +++---
 lib/libtelnet/forward.c    |   2 +-
 lib/libtelnet/kerberos.c   |   8 ++++----
 lib/libtelnet/krb4encpwd.c |  12 ++++++------
 lib/libtelnet/spx.c        |  26 ++++++++++++++------------
 7 files changed, 38 insertions(+), 36 deletions(-)

diffs (281 lines):

diff -r 437335e7d082 -r 359e8a6681a9 lib/libtelnet/auth.c
--- a/lib/libtelnet/auth.c      Tue Jul 15 05:03:49 2003 +0000
+++ b/lib/libtelnet/auth.c      Tue Jul 15 05:09:34 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: auth.c,v 1.13 2003/07/14 08:36:27 itojun Exp $ */
+/*     $NetBSD: auth.c,v 1.14 2003/07/15 05:09:34 itojun Exp $ */
 
 /*-
  * Copyright (c) 1991, 1993
@@ -38,7 +38,7 @@
 #if 0
 static char sccsid[] = "@(#)auth.c     8.3 (Berkeley) 5/30/95"
 #else
-__RCSID("$NetBSD: auth.c,v 1.13 2003/07/14 08:36:27 itojun Exp $");
+__RCSID("$NetBSD: auth.c,v 1.14 2003/07/15 05:09:34 itojun Exp $");
 #endif
 #endif /* not lint */
 
@@ -668,7 +668,7 @@
        buf[buflen-2] = '*';
        buflen -= 2;
        for (; cnt > 0; cnt--, data++) {
-               sprintf((char *)tbuf, " %d", *data);
+               snprintf((char *)tbuf, sizeof(tbuf), " %d", *data);
                for (cp = tbuf; *cp && buflen > 0; --buflen)
                        *buf++ = *cp++;
                if (buflen <= 0)
diff -r 437335e7d082 -r 359e8a6681a9 lib/libtelnet/enc_des.c
--- a/lib/libtelnet/enc_des.c   Tue Jul 15 05:03:49 2003 +0000
+++ b/lib/libtelnet/enc_des.c   Tue Jul 15 05:09:34 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: enc_des.c,v 1.9 2002/08/29 14:53:21 itojun Exp $       */
+/*     $NetBSD: enc_des.c,v 1.10 2003/07/15 05:09:34 itojun Exp $      */
 
 /*-
  * Copyright (c) 1991, 1993
@@ -38,7 +38,7 @@
 #if 0
 static char sccsid[] = "@(#)enc_des.c  8.3 (Berkeley) 5/30/95"; */
 #else
-__RCSID("$NetBSD: enc_des.c,v 1.9 2002/08/29 14:53:21 itojun Exp $");
+__RCSID("$NetBSD: enc_des.c,v 1.10 2003/07/15 05:09:34 itojun Exp $");
 #endif
 #endif /* not lint */
 
@@ -500,28 +500,28 @@
 
        switch(data[2]) {
        case FB64_IV:
-               sprintf(lbuf, "%s_IV", type);
+               snprintf(lbuf, sizeof(lbuf), "%s_IV", type);
                cp = lbuf;
                goto common;
 
        case FB64_IV_OK:
-               sprintf(lbuf, "%s_IV_OK", type);
+               snprintf(lbuf, sizeof(lbuf), "%s_IV_OK", type);
                cp = lbuf;
                goto common;
 
        case FB64_IV_BAD:
-               sprintf(lbuf, "%s_IV_BAD", type);
+               snprintf(lbuf, sizeof(lbuf), "%s_IV_BAD", type);
                cp = lbuf;
                goto common;
 
        default:
-               sprintf(lbuf, " %d (unknown)", data[2]);
+               snprintf(lbuf, sizeof(lbuf), " %d (unknown)", data[2]);
                cp = lbuf;
        common:
                for (; (buflen > 0) && (*buf = *cp++); buf++)
                        buflen--;
                for (i = 3; i < cnt; i++) {
-                       sprintf(lbuf, " %d", data[i]);
+                       snprintf(lbuf, sizeof(lbuf), " %d", data[i]);
                        for (cp = lbuf; (buflen > 0) && (*buf = *cp++); buf++)
                                buflen--;
                }
diff -r 437335e7d082 -r 359e8a6681a9 lib/libtelnet/encrypt.c
--- a/lib/libtelnet/encrypt.c   Tue Jul 15 05:03:49 2003 +0000
+++ b/lib/libtelnet/encrypt.c   Tue Jul 15 05:09:34 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: encrypt.c,v 1.10 2003/01/20 05:29:57 simonb Exp $      */
+/*     $NetBSD: encrypt.c,v 1.11 2003/07/15 05:09:34 itojun Exp $      */
 
 /*-
  * Copyright (c) 1991, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)encrypt.c  8.2 (Berkeley) 5/30/95";
 #else
-__RCSID("$NetBSD: encrypt.c,v 1.10 2003/01/20 05:29:57 simonb Exp $");
+__RCSID("$NetBSD: encrypt.c,v 1.11 2003/07/15 05:09:34 itojun Exp $");
 #endif /* not lint */
 
 /*
@@ -980,7 +980,7 @@
        buf[buflen-2] = '*';
        buflen -= 2;
        for (; cnt > 0; cnt--, data++) {
-               sprintf(tbuf, " %d", *data);
+               snprintf(tbuf, sizeof(tbuf), " %d", *data);
                for (cp = tbuf; *cp && buflen > 0; --buflen)
                        *buf++ = *cp++;
                if (buflen <= 0)
diff -r 437335e7d082 -r 359e8a6681a9 lib/libtelnet/forward.c
--- a/lib/libtelnet/forward.c   Tue Jul 15 05:03:49 2003 +0000
+++ b/lib/libtelnet/forward.c   Tue Jul 15 05:09:34 2003 +0000
@@ -51,7 +51,7 @@
     if ((retval = krb5_rd_cred(context, auth_context, inbuf, &creds, NULL)) != 0) 
        return(retval);
 
-    sprintf(ccname, "FILE:/tmp/krb5cc_p%d", getpid());
+    snprintf(ccname, sizeof(ccname), "FILE:/tmp/krb5cc_p%d", getpid());
     setenv(KRB5_ENV_CCNAME, ccname, 1);
 
     if ((retval = krb5_cc_resolve(context, ccname, &ccache)) != 0)
diff -r 437335e7d082 -r 359e8a6681a9 lib/libtelnet/kerberos.c
--- a/lib/libtelnet/kerberos.c  Tue Jul 15 05:03:49 2003 +0000
+++ b/lib/libtelnet/kerberos.c  Tue Jul 15 05:09:34 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kerberos.c,v 1.10 2002/11/05 22:34:50 thorpej Exp $    */
+/*     $NetBSD: kerberos.c,v 1.11 2003/07/15 05:09:35 itojun Exp $     */
 
 /*-
  * Copyright (c) 1991, 1993
@@ -38,7 +38,7 @@
 #if 0
 static char sccsid[] = "@(#)kerberos.c 8.3 (Berkeley) 5/30/95";
 #else
-__RCSID("$NetBSD: kerberos.c,v 1.10 2002/11/05 22:34:50 thorpej Exp $");
+__RCSID("$NetBSD: kerberos.c,v 1.11 2003/07/15 05:09:35 itojun Exp $");
 #endif
 #endif /* not lint */
 
@@ -494,12 +494,12 @@
                goto common2;
 
        default:
-               sprintf(lbuf, " %d (unknown)", data[3]);
+               snprintf(lbuf, sizeof(lbuf), " %d (unknown)", data[3]);
                strncpy((char *)buf, lbuf, buflen);
        common2:
                BUMP(buf, buflen);
                for (i = 4; i < cnt; i++) {
-                       sprintf(lbuf, " %d", data[i]);
+                       snprintf(lbuf, sizeof(lbuf), " %d", data[i]);
                        strncpy((char *)buf, lbuf, buflen);
                        BUMP(buf, buflen);
                }
diff -r 437335e7d082 -r 359e8a6681a9 lib/libtelnet/krb4encpwd.c
--- a/lib/libtelnet/krb4encpwd.c        Tue Jul 15 05:03:49 2003 +0000
+++ b/lib/libtelnet/krb4encpwd.c        Tue Jul 15 05:09:34 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: krb4encpwd.c,v 1.2 2002/05/26 22:07:28 wiz Exp $       */
+/*     $NetBSD: krb4encpwd.c,v 1.3 2003/07/15 05:09:35 itojun Exp $    */
 
 /*-
  * Copyright (c) 1992, 1993
@@ -38,7 +38,7 @@
 #if 0
 static char sccsid[] = "@(#)krb4encpwd.c       8.3 (Berkeley) 5/30/95";
 #else
-__RCSID("$NetBSD: krb4encpwd.c,v 1.2 2002/05/26 22:07:28 wiz Exp $");
+__RCSID("$NetBSD: krb4encpwd.c,v 1.3 2003/07/15 05:09:35 itojun Exp $");
 #endif
 #endif /* not lint */
 
@@ -269,7 +269,7 @@
                  register int i;
 
                  time(&now);
-                 sprintf(challenge, "%x", now);
+                 snprintf(challenge, sizeof(challenge), "%x", now);
                  Data(ap, KRB4_ENCPWD_CHALLENGE, (void *)challenge, strlen(challenge));
                }
                break;
@@ -322,7 +322,7 @@
                local_des_read_pw_string(user_passwd, sizeof(user_passwd)-1, "Password: ", 0);
                UserPassword = user_passwd;
                Challenge = challenge;
-               strcpy(instance, RemoteHostName);
+               strlcpy(instance, RemoteHostName, sizeof(instance));
                if ((cp = strchr(instance, '.')) != 0)  *cp = '\0';
 
                if (r = krb_mk_encpwd_req(&krb_token, KRB_SERVICE_NAME, instance, realm, Challenge, UserNameRequested, user_passwd)) {
@@ -403,12 +403,12 @@
                goto common2;
 
        default:
-               sprintf(lbuf, " %d (unknown)", data[3]);
+               snprintf(lbuf, sizeof(lbuf), " %d (unknown)", data[3]);
                strncpy((char *)buf, lbuf, buflen);
        common2:
                BUMP(buf, buflen);
                for (i = 4; i < cnt; i++) {
-                       sprintf(lbuf, " %d", data[i]);
+                       snprintf(lbuf, sizeof(lbuf), " %d", data[i]);
                        strncpy((char *)buf, lbuf, buflen);
                        BUMP(buf, buflen);
                }
diff -r 437335e7d082 -r 359e8a6681a9 lib/libtelnet/spx.c
--- a/lib/libtelnet/spx.c       Tue Jul 15 05:03:49 2003 +0000
+++ b/lib/libtelnet/spx.c       Tue Jul 15 05:09:34 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: spx.c,v 1.2 2002/05/26 22:07:28 wiz Exp $ */
+/*     $NetBSD: spx.c,v 1.3 2003/07/15 05:09:35 itojun Exp $ */
 
 /*-
  * Copyright (c) 1992, 1993
@@ -39,7 +39,7 @@
 #if 0
 static char sccsid[] = "@(#)spx.c      8.2 (Berkeley) 5/30/95";
 #else
-__RCSID("$NetBSD: spx.c,v 1.2 2002/05/26 22:07:28 wiz Exp $");
+__RCSID("$NetBSD: spx.c,v 1.3 2003/07/15 05:09:35 itojun Exp $");
 #endif
 #endif /* not lint */
 
@@ -180,8 +180,9 @@
        if (server) {
                str_data[3] = TELQUAL_REPLY;
                gethostname(lhostname, sizeof(lhostname));
-               strcpy(targ_printable, "SERVICE:rcmd@");
-               strcat(targ_printable, lhostname);
+               strlcpy(targ_printable, "SERVICE:rcmd@",
+                   sizeof(targ_printable));
+               strlcat(targ_printable, lhostname, sizeof(targ_printable));
                input_name_buffer.length = strlen(targ_printable);
                input_name_buffer.value = targ_printable;
                major_status = gss_import_name(&status,
@@ -223,8 +224,8 @@
        char *address;
 
        printf("[ Trying SPX ... ]\n");
-       strcpy(targ_printable, "SERVICE:rcmd@");
-       strcat(targ_printable, RemoteHostName);
+       strlcpy(targ_printable, "SERVICE:rcmd@", sizeof(targ_printable));
+       strlcat(targ_printable, RemoteHostName, sizeof(targ_printable));
 
        input_name_buffer.length = strlen(targ_printable);
        input_name_buffer.value = targ_printable;
@@ -331,8 +332,9 @@
 
                gethostname(lhostname, sizeof(lhostname));
 
-               strcpy(targ_printable, "SERVICE:rcmd@");
-               strcat(targ_printable, lhostname);
+               strlcpy(targ_printable, "SERVICE:rcmd@",
+                   sizeof(targ_printable));
+               strlcat(targ_printable, lhostname, sizeof(targ_printable));
 
                input_name_buffer.length = strlen(targ_printable);
                input_name_buffer.value = targ_printable;
@@ -502,8 +504,8 @@
          return(AUTH_USER);   /*  not authenticated  */
        }
 
-       strcpy(acl_file, pwd->pw_dir);
-       strcat(acl_file, "/.sphinx");
+       strlcpy(acl_file, pwd->pw_dir, sizeof(acl_file));
+       strlcat(acl_file, "/.sphinx", sizeof(acl_file));
        acl_file_buffer.value = acl_file;
        acl_file_buffer.length = strlen(acl_file);
 
@@ -564,12 +566,12 @@
                goto common2;
 
        default:
-               sprintf(lbuf, " %d (unknown)", data[3]);
+               snprintf(lbuf, sizeof(lbuf), " %d (unknown)", data[3]);
                strncpy((char *)buf, lbuf, buflen);
        common2:
                BUMP(buf, buflen);
                for (i = 4; i < cnt; i++) {
-                       sprintf(lbuf, " %d", data[i]);
+                       snprintf(lbuf, sizeof(lbuf), " %d", data[i]);
                        strncpy((char *)buf, lbuf, buflen);
                        BUMP(buf, buflen);
                }



Home | Main Index | Thread Index | Old Index