blob: 36b35712f6c7318ec92fc6f7182c1a3f918abd0c [file] [log] [blame]
/*
* Copyright (c) 2024-2025, Altera Corporation. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#include <string.h>
size_t strnlen_secure(const char *str, size_t maxlen)
{
size_t len = 0;
if (str == NULL) {
return 0;
}
while ((len < maxlen) && (str[len] != '\0')) {
len++;
}
return len;
}