Use '%n' instead of strnlen().