mirror of
https://codeberg.org/libreboot/lbmk.git
synced 2026-07-18 14:12:44 +02:00
util/nvmutil: don't use SSIZE_MAX (not portable)
some old systems don't have ssize_t or size_t Signed-off-by: Leah Rowe <leah@libreboot.org>
This commit is contained in:
@@ -543,8 +543,8 @@ static const char *mac_str = rmac;
|
|||||||
static const char *fname = NULL;
|
static const char *fname = NULL;
|
||||||
static const char *argv0;
|
static const char *argv0;
|
||||||
|
|
||||||
#ifndef SSIZE_MAX
|
#ifndef X_LONG_MAX
|
||||||
#define SSIZE_MAX ((ssize_t)(~((size_t)1 << (sizeof(ssize_t)*CHAR_BIT-1))))
|
#define X_LONG_MAX ((long)(~((long)1 << (sizeof(long)*CHAR_BIT-1))))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -2586,7 +2586,7 @@ io_args(int fd, void *mem, size_t nrw,
|
|||||||
goto err_io_args;
|
goto err_io_args;
|
||||||
|
|
||||||
/* prevent overflow */
|
/* prevent overflow */
|
||||||
if (nrw > (size_t)SSIZE_MAX)
|
if (nrw > (size_t)X_LONG_MAX)
|
||||||
goto err_io_args;
|
goto err_io_args;
|
||||||
|
|
||||||
/* prevent overflow */
|
/* prevent overflow */
|
||||||
@@ -2639,14 +2639,14 @@ rw_over_nrw(ssize_t r, size_t nrw)
|
|||||||
if (r == -1)
|
if (r == -1)
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
if ((size_t)r > SSIZE_MAX) {
|
if ((size_t)r > X_LONG_MAX) {
|
||||||
/*
|
/*
|
||||||
* Theoretical buggy libc
|
* Theoretical buggy libc
|
||||||
* check. Extremely academic.
|
* check. Extremely academic.
|
||||||
*
|
*
|
||||||
* Specifications never
|
* Specifications never
|
||||||
* allow this return value
|
* allow this return value
|
||||||
* to exceed SSIZE_MAX, but
|
* to exceed SSIZE_T, but
|
||||||
* spec != implementation
|
* spec != implementation
|
||||||
*
|
*
|
||||||
* Check this after using
|
* Check this after using
|
||||||
|
|||||||
Reference in New Issue
Block a user