diff options
| author | Peter Jones <pjones@redhat.com> | 2021-02-15 11:41:08 -0500 |
|---|---|---|
| committer | Jan Setje-Eilers <73182357+jsetje@users.noreply.github.com> | 2021-02-17 16:27:18 -0800 |
| commit | 07724ab645593b5aa6d9ba0cf35aad4af29080ab (patch) | |
| tree | 7ee0e27a204533dab2b9890e60225edc32755fb7 | |
| parent | 066a11164e5f1135b2e95940b5c526c9e221d23e (diff) | |
| download | efi-boot-shim-07724ab645593b5aa6d9ba0cf35aad4af29080ab.tar.gz efi-boot-shim-07724ab645593b5aa6d9ba0cf35aad4af29080ab.zip | |
Fix an off by one in strnlena()
I wrote a test case for strnlena() and strndupa() and of course both
were off by one in the opposite directions...
... but the next patch obviates the need for them, hopefully, so this
will wind up getting dropped.
| -rw-r--r-- | include/str.h | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/include/str.h b/include/str.h index eee83369..14089c76 100644 --- a/include/str.h +++ b/include/str.h @@ -3,12 +3,11 @@ #ifndef SHIM_STR_H #define SHIM_STR_H -static inline -__attribute__((unused)) -unsigned long strnlena(const CHAR8 *s, unsigned long n) +static inline __attribute__((unused)) unsigned long +strnlena(const CHAR8 *s, unsigned long n) { unsigned long i; - for (i = 0; i <= n; i++) + for (i = 0; i < n; i++) if (s[i] == '\0') break; return i; |
