In a C program I have a function that writes a message to a log file
LogResult writeLog(const char* format, ...)
That function passes its arguments on to 'vfprintf()' as a 'format' string and a 'va_list'. It just occurred to me that I don't have any control over what would happen if someone were to pass an unterminated string, e.g.
const char unterminatedString[5] = {'h', 'e', 'l', 'l', 'o'};
writeLog("Log message: %s", unterminatedString);
Is there any way to guard against this?