mirror of
https://github.com/openssl/openssl.git
synced 2025-04-06 20:20:50 +08:00
Avoid NULL+X UB in bss_mem.c
Fixes #16816 Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: Bernd Edlinger <bernd.edlinger@hotmail.de> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/16818)
This commit is contained in:
parent
5fdc95e443
commit
a98b26588b
@ -254,7 +254,7 @@ static long mem_ctrl(BIO *b, int cmd, long num, void *ptr)
|
||||
bm = bbm->readp;
|
||||
bo = bbm->buf;
|
||||
}
|
||||
off = bm->data - bo->data;
|
||||
off = (bm->data == bo->data) ? 0 : bm->data - bo->data;
|
||||
remain = bm->length;
|
||||
|
||||
switch (cmd) {
|
||||
@ -277,7 +277,7 @@ static long mem_ctrl(BIO *b, int cmd, long num, void *ptr)
|
||||
if (num < 0 || num > off + remain)
|
||||
return -1; /* Can't see outside of the current buffer */
|
||||
|
||||
bm->data = bo->data + num;
|
||||
bm->data = (num != 0) ? bo->data + num : bo->data;
|
||||
bm->length = bo->length - num;
|
||||
bm->max = bo->max - num;
|
||||
off = num;
|
||||
|
Loading…
x
Reference in New Issue
Block a user