1
0
mirror of https://github.com/openbsd/src.git synced 2026-04-30 17:16:30 +00:00

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
This commit is contained in:
tb
2025-05-24 19:45:34 +00:00
parent e8d1b0978a
commit ae496ce11d

View File

@@ -1,4 +1,4 @@
/* $OpenBSD: bss_mem.c,v 1.25 2025/05/24 19:43:09 tb Exp $ */
/* $OpenBSD: bss_mem.c,v 1.26 2025/05/24 19:45:34 tb Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
@@ -162,6 +162,12 @@ mem_new(BIO *bio)
free(bm);
return 0;
}
if (BUF_MEM_grow_clean(bm->buf, 64) != 64) {
BUF_MEM_free(bm->buf);
free(bm);
return 0;
}
bm->buf->length = 0;
bio->shutdown = 1;
bio->init = 1;