The previous implementation passed `length - str_len` to `snprintf()`, yet compared the return value to `length`. This is incorrect, as `length` is not the buffer size provided to `snprintf()`.
The previous implementation passed `length - str_len` to `snprintf()`, yet compared the return value to `length`. This is incorrect, as `length` is not the buffer size provided to `snprintf()`.