Mon Feb 20 01:33:28 2017 UTC ()
Remove a useless loop around getpass()

According to getpass(3), this library function cannot return NULL.
Verified with a source code inspection.


(khorben)
diff -r1.49 -r1.50 src/crypto/external/bsd/netpgp/dist/src/lib/reader.c

cvs diff -r1.49 -r1.50 src/crypto/external/bsd/netpgp/dist/src/lib/reader.c (expand / switch to unified diff)

--- src/crypto/external/bsd/netpgp/dist/src/lib/reader.c 2012/03/05 02:20:18 1.49
+++ src/crypto/external/bsd/netpgp/dist/src/lib/reader.c 2017/02/20 01:33:28 1.50
@@ -44,27 +44,27 @@ @@ -44,27 +44,27 @@
44 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 44 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
45 * 45 *
46 * See the License for the specific language governing permissions and 46 * See the License for the specific language governing permissions and
47 * limitations under the License. 47 * limitations under the License.
48 */ 48 */
49#include "config.h" 49#include "config.h"
50 50
51#ifdef HAVE_SYS_CDEFS_H 51#ifdef HAVE_SYS_CDEFS_H
52#include <sys/cdefs.h> 52#include <sys/cdefs.h>
53#endif 53#endif
54 54
55#if defined(__NetBSD__) 55#if defined(__NetBSD__)
56__COPYRIGHT("@(#) Copyright (c) 2009 The NetBSD Foundation, Inc. All rights reserved."); 56__COPYRIGHT("@(#) Copyright (c) 2009 The NetBSD Foundation, Inc. All rights reserved.");
57__RCSID("$NetBSD: reader.c,v 1.49 2012/03/05 02:20:18 christos Exp $"); 57__RCSID("$NetBSD: reader.c,v 1.50 2017/02/20 01:33:28 khorben Exp $");
58#endif 58#endif
59 59
60#include <sys/types.h> 60#include <sys/types.h>
61#include <sys/stat.h> 61#include <sys/stat.h>
62 62
63#ifdef HAVE_SYS_MMAN_H 63#ifdef HAVE_SYS_MMAN_H
64#include <sys/mman.h> 64#include <sys/mman.h>
65#endif 65#endif
66 66
67#ifdef HAVE_SYS_PARAM_H  67#ifdef HAVE_SYS_PARAM_H
68#include <sys/param.h> 68#include <sys/param.h>
69#endif 69#endif
70 70
@@ -152,28 +152,27 @@ read_partial_data(pgp_stream_t *stream,  @@ -152,28 +152,27 @@ read_partial_data(pgp_stream_t *stream,
152 stream->virtualpkt = NULL; 152 stream->virtualpkt = NULL;
153 stream->virtualc = stream->virtualoff = 0; 153 stream->virtualc = stream->virtualoff = 0;
154 } 154 }
155 return (int)n; 155 return (int)n;
156} 156}
157 157
158/* get a pass phrase from the user */ 158/* get a pass phrase from the user */
159int 159int
160pgp_getpassphrase(void *in, char *phrase, size_t size) 160pgp_getpassphrase(void *in, char *phrase, size_t size)
161{ 161{
162 char *p; 162 char *p;
163 163
164 if (in == NULL) { 164 if (in == NULL) {
165 while ((p = getpass("netpgp passphrase: ")) == NULL) { 165 p = getpass("netpgp passphrase: ");
166 } 
167 (void) snprintf(phrase, size, "%s", p); 166 (void) snprintf(phrase, size, "%s", p);
168 } else { 167 } else {
169 if (fgets(phrase, (int)size, in) == NULL) { 168 if (fgets(phrase, (int)size, in) == NULL) {
170 return 0; 169 return 0;
171 } 170 }
172 phrase[strlen(phrase) - 1] = 0x0; 171 phrase[strlen(phrase) - 1] = 0x0;
173 } 172 }
174 return 1; 173 return 1;
175} 174}
176 175
177/** 176/**
178 * \ingroup Internal_Readers_Generic 177 * \ingroup Internal_Readers_Generic
179 * \brief Starts reader stack 178 * \brief Starts reader stack