Closed asteinha closed 5 years ago
What if we went in a different direction, where everything used
uint8_t
and the only place we did a cast was inmain()
when we pass aconst char*
toleak_byte
?
Then we won't be able to use strlen. Or you want to call strlen on public_data directly?
I think the fact that the data we're leaking is a null-terminated string should be "forgotten" as early as possible. Everything else in the system should deal with uint8_t*
pointers with an associated length.
So yes, we'd call strlen
very early on, directly on public_data
.
OK, I'll fix that in another PR.
Cast of char with ascii code between 128 and 255 to size_t gives wrong results (extremely high numbers instead of the ASCII codes). Casting it first to unsigned char and then to size_t implicitly seems to work correctly.