lib: add generic strnlen_user() function