From: tb Date: Wed, 23 Nov 2022 08:58:34 +0000 (+0000) Subject: bn_unit: appease coverity X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=4ed111a22e4101d25528157a72648dad7045a08e;p=openbsd bn_unit: appease coverity Apparently, the '0' in memset(a, '0', size - 1); could be a typo for '\0'. Randomize the decimal digit to make the intent clear. CID 377009 --- diff --git a/regress/lib/libcrypto/bn/general/bn_unit.c b/regress/lib/libcrypto/bn/general/bn_unit.c index f1a2c780f79..6ae67659988 100644 --- a/regress/lib/libcrypto/bn/general/bn_unit.c +++ b/regress/lib/libcrypto/bn/general/bn_unit.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bn_unit.c,v 1.3 2022/11/23 08:01:05 tb Exp $ */ +/* $OpenBSD: bn_unit.c,v 1.4 2022/11/23 08:58:34 tb Exp $ */ /* * Copyright (c) 2022 Theo Buehler @@ -45,6 +45,7 @@ test_bn_print_null_derefs(void) size_t size = INT_MAX / 4 + 4; size_t datalimit = (size + 500 * 1024) / 1024; char *a; + char digit; int failed = 0; if ((a = malloc(size)) == NULL) { @@ -53,7 +54,10 @@ test_bn_print_null_derefs(void) return 0; } - memset(a, '0', size - 1); + /* Fill with a random digit since coverity doesn't like us using '0'. */ + digit = '0' + arc4random_uniform(10); + + memset(a, digit, size - 1); a[size - 1] = '\0'; failed |= test_bn_print_wrapper(a, size, "BN_dec2bn", BN_dec2bn);