strcpy error

6 views
Skip to first unread message

Ingo Foerster

unread,
Sep 14, 2021, 12:54:03 PMSep 14
to android-ndk

Why the NDK nags around this code?

  char StandardIdentifier[5];
  strcpy(cTermVolumeDesc.StandardIdentifier, "CD001");

Error message while compile: error: 'strcpy' called with string bigger than buffer
Never got any problems with this on Linux, macOS and Windows.

I build with lines:
cmake {
arguments '-DANDROID_PLATFORM=android-29','-DANDROID_TOOLCHAIN=clang','-DANDROID_ARM_NEON=TRUE','-DANDROID_STL=c++_static'
cFlags '-O3', '-fsigned-char'
cppFlags '-std=c++11', '-fsigned-char', '-fPIC'
}

Luiz Valdetaro

unread,
Sep 14, 2021, 4:21:40 PMSep 14
to andro...@googlegroups.com
"CD001" has a size of 6, not 5. Don't forget the null-character at the end

--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-ndk...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/android-ndk/1ea55e65-62c8-430a-b1ec-d4c61020804dn%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages