irods / irods_capability_storage_tiering

BSD 3-Clause "New" or "Revised" License
5 stars 10 forks source link

Undefined behavior: Using plain `char`s with `tolower` #237

Closed alanking closed 9 months ago

alanking commented 9 months ago

The use of tolower in the manner of line 225 here is undefined behavior: https://github.com/irods/irods_capability_storage_tiering/blob/b50254bad08d8f24b63e91dce01c5c61f455a0ca/storage_tiering.cpp#L213-L231

See "Notes" section here: https://en.cppreference.com/w/cpp/string/byte/tolower

Like all other functions from \<cctype>, the behavior of std::tolower is undefined if the argument's value is neither representable as unsigned char nor equal to EOF. To use these functions safely with plain chars (or signed chars), the argument should first be converted to unsigned char[.]