Partager via


strlen_s, where for art thou?

I just received an email from a product group wanting to replace a small number of calls to strlen with strlen_s to help them be SDL compliant. Problem is, there is no strlen_s! :(

So I had a chat with Martyn Lovell, who headed the SafeCRT work to find out where the function has disappeared to. It turns out it's there alright, but the ISO folks didn't like the naming, the correct name is strnlen_s, which maps to strnlen:

static

__inline __checkReturn size_t __CRTDECL strnlen_s(__in_ecount_z(_MaxCount) const char * _Str, __in size_t _MaxCount)
{
return strnlen(_Str, _MaxCount);
}

Comments

  • Anonymous
    January 18, 2006
    Any useful URLs? To "the ISO folks" perhaps, to SafeCRT people, and documentation produced by them... I'd like to do some (more) reading.

    Have "the ISO folks" picked up the specstring.h stuff, apparently... And weren't its conditions checked only in the DDK build and VS Team, or do I remember wrongly?

    Alan
  • Anonymous
    January 19, 2006
    "Where for" means "why", so your title roughly translates to "strlen_s, why are you?".