diff options
author | miod <> | 2003-02-23 16:16:02 +0000 |
---|---|---|
committer | miod <> | 2003-02-23 16:16:02 +0000 |
commit | 8d1a9d230c928e48c45a1800d762f52a13d614a0 (patch) | |
tree | 87c9449a0de75690278b39a8cb5e23569f69c563 | |
parent | 87d7c154b9268b39059a87e45807e00030655fbf (diff) | |
download | openbsd-8d1a9d230c928e48c45a1800d762f52a13d614a0.tar.gz openbsd-8d1a9d230c928e48c45a1800d762f52a13d614a0.tar.bz2 openbsd-8d1a9d230c928e48c45a1800d762f52a13d614a0.zip |
MFC (markus@):
check for size < 0 when allocating memory, from openssl (-r1.34)
-rw-r--r-- | src/lib/libcrypto/mem.c | 6 | ||||
-rw-r--r-- | src/lib/libssl/src/crypto/mem.c | 6 |
2 files changed, 12 insertions, 0 deletions
diff --git a/src/lib/libcrypto/mem.c b/src/lib/libcrypto/mem.c index 3b5b2bbc68..c0dc37c4bd 100644 --- a/src/lib/libcrypto/mem.c +++ b/src/lib/libcrypto/mem.c | |||
@@ -174,6 +174,8 @@ void *CRYPTO_malloc_locked(int num, const char *file, int line) | |||
174 | { | 174 | { |
175 | void *ret = NULL; | 175 | void *ret = NULL; |
176 | 176 | ||
177 | if (num < 0) return NULL; | ||
178 | |||
177 | allow_customize = 0; | 179 | allow_customize = 0; |
178 | if (malloc_debug_func != NULL) | 180 | if (malloc_debug_func != NULL) |
179 | { | 181 | { |
@@ -206,6 +208,8 @@ void *CRYPTO_malloc(int num, const char *file, int line) | |||
206 | { | 208 | { |
207 | void *ret = NULL; | 209 | void *ret = NULL; |
208 | 210 | ||
211 | if (num < 0) return NULL; | ||
212 | |||
209 | allow_customize = 0; | 213 | allow_customize = 0; |
210 | if (malloc_debug_func != NULL) | 214 | if (malloc_debug_func != NULL) |
211 | { | 215 | { |
@@ -226,6 +230,8 @@ void *CRYPTO_realloc(void *str, int num, const char *file, int line) | |||
226 | { | 230 | { |
227 | void *ret = NULL; | 231 | void *ret = NULL; |
228 | 232 | ||
233 | if (num < 0) return NULL; | ||
234 | |||
229 | if (realloc_debug_func != NULL) | 235 | if (realloc_debug_func != NULL) |
230 | realloc_debug_func(str, NULL, num, file, line, 0); | 236 | realloc_debug_func(str, NULL, num, file, line, 0); |
231 | ret = realloc_func(str,num); | 237 | ret = realloc_func(str,num); |
diff --git a/src/lib/libssl/src/crypto/mem.c b/src/lib/libssl/src/crypto/mem.c index 3b5b2bbc68..c0dc37c4bd 100644 --- a/src/lib/libssl/src/crypto/mem.c +++ b/src/lib/libssl/src/crypto/mem.c | |||
@@ -174,6 +174,8 @@ void *CRYPTO_malloc_locked(int num, const char *file, int line) | |||
174 | { | 174 | { |
175 | void *ret = NULL; | 175 | void *ret = NULL; |
176 | 176 | ||
177 | if (num < 0) return NULL; | ||
178 | |||
177 | allow_customize = 0; | 179 | allow_customize = 0; |
178 | if (malloc_debug_func != NULL) | 180 | if (malloc_debug_func != NULL) |
179 | { | 181 | { |
@@ -206,6 +208,8 @@ void *CRYPTO_malloc(int num, const char *file, int line) | |||
206 | { | 208 | { |
207 | void *ret = NULL; | 209 | void *ret = NULL; |
208 | 210 | ||
211 | if (num < 0) return NULL; | ||
212 | |||
209 | allow_customize = 0; | 213 | allow_customize = 0; |
210 | if (malloc_debug_func != NULL) | 214 | if (malloc_debug_func != NULL) |
211 | { | 215 | { |
@@ -226,6 +230,8 @@ void *CRYPTO_realloc(void *str, int num, const char *file, int line) | |||
226 | { | 230 | { |
227 | void *ret = NULL; | 231 | void *ret = NULL; |
228 | 232 | ||
233 | if (num < 0) return NULL; | ||
234 | |||
229 | if (realloc_debug_func != NULL) | 235 | if (realloc_debug_func != NULL) |
230 | realloc_debug_func(str, NULL, num, file, line, 0); | 236 | realloc_debug_func(str, NULL, num, file, line, 0); |
231 | ret = realloc_func(str,num); | 237 | ret = realloc_func(str,num); |