diff options
author | miod <> | 2014-09-29 04:17:24 +0000 |
---|---|---|
committer | miod <> | 2014-09-29 04:17:24 +0000 |
commit | b9058e3a0925c64cba4c450d054e5f8818edfb17 (patch) | |
tree | 5cada5317c43d09b96a02a6097ee63351c67995c /src/lib | |
parent | b4000a83a9f63dffe9a50cb6a1ded52c310da626 (diff) | |
download | openbsd-b9058e3a0925c64cba4c450d054e5f8818edfb17.tar.gz openbsd-b9058e3a0925c64cba4c450d054e5f8818edfb17.tar.bz2 openbsd-b9058e3a0925c64cba4c450d054e5f8818edfb17.zip |
X509_NAME_get_text_by_OBJ(): make sure we do not pass a negative size to
memcpy().
ok bcook@
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/libcrypto/x509/x509name.c | 8 | ||||
-rw-r--r-- | src/lib/libssl/src/crypto/x509/x509name.c | 8 |
2 files changed, 10 insertions, 6 deletions
diff --git a/src/lib/libcrypto/x509/x509name.c b/src/lib/libcrypto/x509/x509name.c index 465a1cadb5..14634013cf 100644 --- a/src/lib/libcrypto/x509/x509name.c +++ b/src/lib/libcrypto/x509/x509name.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: x509name.c,v 1.12 2014/07/11 08:44:49 jsing Exp $ */ | 1 | /* $OpenBSD: x509name.c,v 1.13 2014/09/29 04:17:24 miod Exp $ */ |
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
@@ -91,8 +91,10 @@ X509_NAME_get_text_by_OBJ(X509_NAME *name, ASN1_OBJECT *obj, char *buf, | |||
91 | i = (data->length > (len - 1)) ? (len - 1) : data->length; | 91 | i = (data->length > (len - 1)) ? (len - 1) : data->length; |
92 | if (buf == NULL) | 92 | if (buf == NULL) |
93 | return (data->length); | 93 | return (data->length); |
94 | memcpy(buf, data->data, i); | 94 | if (i >= 0) { |
95 | buf[i] = '\0'; | 95 | memcpy(buf, data->data, i); |
96 | buf[i] = '\0'; | ||
97 | } | ||
96 | return (i); | 98 | return (i); |
97 | } | 99 | } |
98 | 100 | ||
diff --git a/src/lib/libssl/src/crypto/x509/x509name.c b/src/lib/libssl/src/crypto/x509/x509name.c index 465a1cadb5..14634013cf 100644 --- a/src/lib/libssl/src/crypto/x509/x509name.c +++ b/src/lib/libssl/src/crypto/x509/x509name.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: x509name.c,v 1.12 2014/07/11 08:44:49 jsing Exp $ */ | 1 | /* $OpenBSD: x509name.c,v 1.13 2014/09/29 04:17:24 miod Exp $ */ |
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
@@ -91,8 +91,10 @@ X509_NAME_get_text_by_OBJ(X509_NAME *name, ASN1_OBJECT *obj, char *buf, | |||
91 | i = (data->length > (len - 1)) ? (len - 1) : data->length; | 91 | i = (data->length > (len - 1)) ? (len - 1) : data->length; |
92 | if (buf == NULL) | 92 | if (buf == NULL) |
93 | return (data->length); | 93 | return (data->length); |
94 | memcpy(buf, data->data, i); | 94 | if (i >= 0) { |
95 | buf[i] = '\0'; | 95 | memcpy(buf, data->data, i); |
96 | buf[i] = '\0'; | ||
97 | } | ||
96 | return (i); | 98 | return (i); |
97 | } | 99 | } |
98 | 100 | ||