NO

Author Topic: Invalid result of the strnlen_s() function in debug 64-bit mode  (Read 1751 times)

Offline Prokrust

  • Member
  • *
  • Posts: 10
Code: [Select]
#define __STDC_WANT_LIB_EXT1__  1
#include <stdio.h>
#include <string.h>

unsigned len_func(const char * ss, unsigned size) {
return (unsigned)strnlen_s(ss,size);
}

int main(int argc, char *argv[]) { (void)argv[argc];
printf("strnlen_s = %llu\n", strnlen_s("qwe",6));
printf("len_func = %u\n", len_func("qwe",6));
return 0;
}
Result in Debug 64-bit mode:
Quote
strnlen_s = 3
len_func = 12
« Last Edit: March 23, 2021, 12:32:21 PM by Prokrust »

Offline John Z

  • Member
  • *
  • Posts: 796
Re: Invalid result of the strnlen_s() function in debug 64-bit mode
« Reply #1 on: May 03, 2021, 11:28:39 AM »
Hi Prokrust,

I'm tried this today and you are right as far as I can tell.  Same code w/o debug produces different results than with using debug mode.

John Z