Source-Changes-HG archive

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

[src/trunk]: src/crypto/external/bsd/netpgp/dist/src/lib Do not truncate pass...



details:   https://anonhg.NetBSD.org/src/rev/d7376e0bcae8
branches:  trunk
changeset: 352348:d7376e0bcae8
user:      khorben <khorben%NetBSD.org@localhost>
date:      Mon Mar 27 20:50:19 2017 +0000

description:
Do not truncate pass-phrases without a newline character

This also fixes a crash when the pass-phrase entered is empty.

Submitted on tech-pkg@ as:
[PATCH 02/11] Do not truncate pass-phrases without a newline character

Only modified for consistency with the coding style.

diffstat:

 crypto/external/bsd/netpgp/dist/src/lib/reader.c |  8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diffs (32 lines):

diff -r 073e0aedd45e -r d7376e0bcae8 crypto/external/bsd/netpgp/dist/src/lib/reader.c
--- a/crypto/external/bsd/netpgp/dist/src/lib/reader.c  Mon Mar 27 18:39:55 2017 +0000
+++ b/crypto/external/bsd/netpgp/dist/src/lib/reader.c  Mon Mar 27 20:50:19 2017 +0000
@@ -54,7 +54,7 @@
 
 #if defined(__NetBSD__)
 __COPYRIGHT("@(#) Copyright (c) 2009 The NetBSD Foundation, Inc. All rights reserved.");
-__RCSID("$NetBSD: reader.c,v 1.51 2017/02/24 01:27:14 khorben Exp $");
+__RCSID("$NetBSD: reader.c,v 1.52 2017/03/27 20:50:19 khorben Exp $");
 #endif
 
 #include <sys/types.h>
@@ -160,6 +160,7 @@
 pgp_getpassphrase(void *in, char *phrase, size_t size)
 {
        char    *p;
+       size_t   len;
 
        if (in == NULL) {
                while ((p = getpass("netpgp passphrase: ")) == NULL) {
@@ -169,7 +170,10 @@
                if (fgets(phrase, (int)size, in) == NULL) {
                        return 0;
                }
-               phrase[strlen(phrase) - 1] = 0x0;
+               len = strlen(phrase);
+               if (len >= 1 && phrase[len - 1] == '\n') {
+                       phrase[len - 1] = '\0';
+               }
        }
        return 1;
 }



Home | Main Index | Thread Index | Old Index