diff options
| author | tb <> | 2025-05-24 19:45:34 +0000 |
|---|---|---|
| committer | tb <> | 2025-05-24 19:45:34 +0000 |
| commit | 8f9b910dab9bb415ae6b6c130c5e1d7bf9045d92 (patch) | |
| tree | fd557221697d0d1fff3dfb2f69a8c613557093d7 /src | |
| parent | fca273f703deb8e39e842b4028f0797813f40bbf (diff) | |
| download | openbsd-8f9b910dab9bb415ae6b6c130c5e1d7bf9045d92.tar.gz openbsd-8f9b910dab9bb415ae6b6c130c5e1d7bf9045d92.tar.bz2 openbsd-8f9b910dab9bb415ae6b6c130c5e1d7bf9045d92.zip | |
Create bm->buf from the start to avoid arithmetic on NULL
This is a different way of avoiding the pointer arithmetic on NULL and
avoids test breakage in pyca/cryptography. This is also a gross hack
that penalizes existing callers of BIO_s_mem(), but this is rarely
called in a hot loop and if so that will most likely be a test.
ok kenjiro joshua jsing
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/libcrypto/bio/bss_mem.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/lib/libcrypto/bio/bss_mem.c b/src/lib/libcrypto/bio/bss_mem.c index 0936ab4e83..f977a123a7 100644 --- a/src/lib/libcrypto/bio/bss_mem.c +++ b/src/lib/libcrypto/bio/bss_mem.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: bss_mem.c,v 1.25 2025/05/24 19:43:09 tb Exp $ */ | 1 | /* $OpenBSD: bss_mem.c,v 1.26 2025/05/24 19:45:34 tb 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 | * |
| @@ -162,6 +162,12 @@ mem_new(BIO *bio) | |||
| 162 | free(bm); | 162 | free(bm); |
| 163 | return 0; | 163 | return 0; |
| 164 | } | 164 | } |
| 165 | if (BUF_MEM_grow_clean(bm->buf, 64) != 64) { | ||
| 166 | BUF_MEM_free(bm->buf); | ||
| 167 | free(bm); | ||
| 168 | return 0; | ||
| 169 | } | ||
| 170 | bm->buf->length = 0; | ||
| 165 | 171 | ||
| 166 | bio->shutdown = 1; | 172 | bio->shutdown = 1; |
| 167 | bio->init = 1; | 173 | bio->init = 1; |
