diff options
| author | Leah Rowe <leah@libreboot.org> | 2026-03-17 18:27:14 +0000 |
|---|---|---|
| committer | Leah Rowe <leah@libreboot.org> | 2026-03-17 18:28:01 +0000 |
| commit | 2cb1797acc417868bd91bcb909ebf26bfe2e5cfc (patch) | |
| tree | 79a834b958f5d493b2fb610d3faaf8310daf6eae /util/nvmutil | |
| parent | cb8ac86bd4595879c592eb32f3b71a0236e16c42 (diff) | |
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 <leah@libreboot.org>
Diffstat (limited to 'util/nvmutil')
| -rw-r--r-- | util/nvmutil/nvmutil.c | 10 |
1 files changed, 7 insertions, 3 deletions
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]; |
