From 2cb1797acc417868bd91bcb909ebf26bfe2e5cfc Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Tue, 17 Mar 2026 18:27:14 +0000 Subject: nvmutil: extremely defensive CHAR_BIT test this program needs bits to be 8 some obscure systems set it to something else Signed-off-by: Leah Rowe --- util/nvmutil/nvmutil.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'util/nvmutil/nvmutil.c') diff --git a/util/nvmutil/nvmutil.c b/util/nvmutil/nvmutil.c index 4d8ad87b..7400a833 100644 --- a/util/nvmutil/nvmutil.c +++ b/util/nvmutil/nvmutil.c @@ -154,6 +154,13 @@ main(int argc, char *argv[]) unsigned long *i; +#ifndef CHAR_BIT + err(ECANCELED, "Unknown char size"); +#else + if (CHAR_BIT != 8) + err(EINVAL, "Unsupported char size"); +#endif + nv = new_xstate(); if (nv == NULL) err(errno, NULL); @@ -165,9 +172,6 @@ main(int argc, char *argv[]) if (nv->f.buf == NULL) err(EINVAL, "Work buffer not initialised"); - if (CHAR_BIT != 8) - err(EINVAL, "Unsupported char size"); - f = &nv->f; f->fname = argv[1]; -- cgit v1.2.1