diff options
| author | Michael Brown | 2025-12-29 15:01:46 +0100 |
|---|---|---|
| committer | Michael Brown | 2025-12-29 15:01:46 +0100 |
| commit | 7c39c04a537ce29dccc6f2bae9749d1d371429c1 (patch) | |
| tree | a6c7e7671d4caa2fb9d772e40462fc2bc36d4208 /src/include/ipxe | |
| parent | [test] Update big integer tests to use okx() (diff) | |
| download | ipxe-7c39c04a537ce29dccc6f2bae9749d1d371429c1.tar.gz ipxe-7c39c04a537ce29dccc6f2bae9749d1d371429c1.tar.xz ipxe-7c39c04a537ce29dccc6f2bae9749d1d371429c1.zip | |
[crypto] Allow for zero-length big integer literals
Ensure that zero-length big integer literals are treated as containing
a zero value. Avoid tests on every big integer arithmetic operation
by ensuring that bigint_required_size() always returns a non-zero
value: the zero-length tests can therefore be restricted to only
bigint_init() and bigint_done().
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/include/ipxe')
| -rw-r--r-- | src/include/ipxe/bigint.h | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/include/ipxe/bigint.h b/src/include/ipxe/bigint.h index 396462f33..9eab89d25 100644 --- a/src/include/ipxe/bigint.h +++ b/src/include/ipxe/bigint.h @@ -28,8 +28,8 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); * @ret size Number of elements */ #define bigint_required_size( len ) \ - ( ( (len) + sizeof ( bigint_element_t ) - 1 ) / \ - sizeof ( bigint_element_t ) ) + ( (len) ? ( ( (len) + sizeof ( bigint_element_t ) - 1 ) / \ + sizeof ( bigint_element_t ) ) : 1 ) /** * Determine number of elements in big-integer type |
