]> andersk Git - openssh.git/commitdiff
- gilles@cvs.openbsd.org 2007/09/11 15:47:17
authordjm <djm>
Mon, 17 Sep 2007 06:09:15 +0000 (06:09 +0000)
committerdjm <djm>
Mon, 17 Sep 2007 06:09:15 +0000 (06:09 +0000)
     [session.c ssh-keygen.c sshlogin.c]
     use strcspn to properly overwrite '\n' in fgets returned buffer
     ok pyr@, ray@, millert@, moritz@, chl@

ChangeLog
session.c
ssh-keygen.c
sshlogin.c

index 52d859cf7831688a83586d878cdd84f1b4c100b2..c9591e3c319aed9e18f9d758f6a6170499e419c5 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
      [sshpty.c]
      sort #include
      NB. RCS ID sync only
+   - gilles@cvs.openbsd.org 2007/09/11 15:47:17
+     [session.c ssh-keygen.c sshlogin.c]
+     use strcspn to properly overwrite '\n' in fgets returned buffer
+     ok pyr@, ray@, millert@, moritz@, chl@
 
 20070914
  - (dtucker) [openbsd-compat/bsd-asprintf.c] Plug mem leak in error path.
index c19c2ac5aa848b83d38956982d523376b56025da..2b0580b45a62496ae1011c98c0a6847c25aef94f 100644 (file)
--- a/session.c
+++ b/session.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: session.c,v 1.223 2007/08/23 02:55:51 djm Exp $ */
+/* $OpenBSD: session.c,v 1.224 2007/09/11 15:47:17 gilles Exp $ */
 /*
  * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
  *                    All rights reserved
@@ -897,8 +897,9 @@ read_environment_file(char ***env, u_int *envsize,
                        ;
                if (!*cp || *cp == '#' || *cp == '\n')
                        continue;
-               if (strchr(cp, '\n'))
-                       *strchr(cp, '\n') = '\0';
+
+               cp[strcspn(cp, "\n")] = '\0';
+
                value = strchr(cp, '=');
                if (value == NULL) {
                        fprintf(stderr, "Bad line %u in %.100s\n", lineno,
index 95b0ac85017db6efe76af461dc0b0776185b96c6..2b2399c50079336d96e99b75d68d19646ce85395 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: ssh-keygen.c,v 1.161 2007/09/09 11:38:01 sobrado Exp $ */
+/* $OpenBSD: ssh-keygen.c,v 1.162 2007/09/11 15:47:17 gilles Exp $ */
 /*
  * Author: Tatu Ylonen <ylo@cs.hut.fi>
  * Copyright (c) 1994 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -141,8 +141,7 @@ ask_filename(struct passwd *pw, const char *prompt)
        fprintf(stderr, "%s (%s): ", prompt, identity_file);
        if (fgets(buf, sizeof(buf), stdin) == NULL)
                exit(1);
-       if (strchr(buf, '\n'))
-               *strchr(buf, '\n') = 0;
+       buf[strcspn(buf, "\n")] = '\0';
        if (strcmp(buf, "") != 0)
                strlcpy(identity_file, buf, sizeof(identity_file));
        have_identity = 1;
@@ -962,8 +961,7 @@ do_change_comment(struct passwd *pw)
                        key_free(private);
                        exit(1);
                }
-               if (strchr(new_comment, '\n'))
-                       *strchr(new_comment, '\n') = 0;
+               new_comment[strcspn(new_comment, "\n")] = '\0';
        }
 
        /* Save the file using the new passphrase. */
index 0059ff8d03937b68eb0f42ff6d8e0329fb2446c4..cc35d6024b41a26573055a71091a41c3f27c46b9 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: sshlogin.c,v 1.25 2006/08/03 03:34:42 deraadt Exp $ */
+/* $OpenBSD: sshlogin.c,v 1.26 2007/09/11 15:47:17 gilles Exp $ */
 /*
  * Author: Tatu Ylonen <ylo@cs.hut.fi>
  * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -98,8 +98,7 @@ store_lastlog_message(const char *user, uid_t uid)
 
        if (last_login_time != 0) {
                time_string = ctime(&last_login_time);
-               if (strchr(time_string, '\n'))
-                   *strchr(time_string, '\n') = '\0';
+               time_string[strcspn(time_string, "\n")] = '\0';
                if (strcmp(hostname, "") == 0)
                        snprintf(buf, sizeof(buf), "Last login: %s\r\n",
                            time_string);
This page took 0.137892 seconds and 5 git commands to generate.