From 6e62847ce043c93089d341b8940940fcca3a4685 Mon Sep 17 00:00:00 2001 From: miod <> Date: Thu, 16 Jul 2015 02:14:48 +0000 Subject: Make sure the `reject negative sizes' logic introduced in 1.34 is actually applied to all code paths. ok beck@ bcook@ doug@ guenther@ --- src/lib/libcrypto/pem/pem_lib.c | 7 ++++--- src/lib/libssl/src/crypto/pem/pem_lib.c | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/lib/libcrypto/pem/pem_lib.c b/src/lib/libcrypto/pem/pem_lib.c index 48768a4467..221b308d71 100644 --- a/src/lib/libcrypto/pem/pem_lib.c +++ b/src/lib/libcrypto/pem/pem_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pem_lib.c,v 1.39 2015/02/11 04:05:14 beck Exp $ */ +/* $OpenBSD: pem_lib.c,v 1.40 2015/07/16 02:14:48 miod Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -94,10 +94,11 @@ PEM_def_callback(char *buf, int num, int w, void *key) int i; const char *prompt; + if (num < 0) + return -1; + if (key) { l = strlen(key); - if (num < 0) - return -1; if (l > (size_t)num) l = (size_t)num; memcpy(buf, key, l); diff --git a/src/lib/libssl/src/crypto/pem/pem_lib.c b/src/lib/libssl/src/crypto/pem/pem_lib.c index 48768a4467..221b308d71 100644 --- a/src/lib/libssl/src/crypto/pem/pem_lib.c +++ b/src/lib/libssl/src/crypto/pem/pem_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pem_lib.c,v 1.39 2015/02/11 04:05:14 beck Exp $ */ +/* $OpenBSD: pem_lib.c,v 1.40 2015/07/16 02:14:48 miod Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -94,10 +94,11 @@ PEM_def_callback(char *buf, int num, int w, void *key) int i; const char *prompt; + if (num < 0) + return -1; + if (key) { l = strlen(key); - if (num < 0) - return -1; if (l > (size_t)num) l = (size_t)num; memcpy(buf, key, l); -- cgit v1.2.3-55-g6feb