fprintf(pFile,msg.c_str());
why do I get a warning in Xcode :
Format string is not a string literal (potentially insecure)
I assume I get this warning to prevent attacks were msg contains some thing like %s
which stream the stack to the screen until it gets to null termination. Is there any safe way to use fprintf
in this case?
You can either give a format string,
fprintf(pFile, "%s", msg.c_str());
or use fputs
,
fputs(msg.c_str(), pFile);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With