To make isValidAbsolutePath function more secure use the strnlen function instead of the strlen.
Calling the strlen function can potentially be unsafe. The strlen function calculates the length of a string by counting characters until it reaches a null character and if the string is not properly null-terminated then strlen will continue reading memory beyond the end of the string, which can lead to undefined behavior or a program crash.
To make
isValidAbsolutePath
function more secure use thestrnlen
function instead of thestrlen
. Calling thestrlen
function can potentially be unsafe. Thestrlen
function calculates the length of a string by counting characters until it reaches a null character and if the string is not properly null-terminated thenstrlen
will continue reading memory beyond the end of the string, which can lead to undefined behavior or a program crash.