epicsStrPrintEscaped() operate on unterminated string
see3a2d225682seef488765631
This commit is contained in:
1 parent
8bfe89b57d
commit
2f20e78e43
3 files changed
+5
-2
No files matched your search
@@ -234,7 +234,7 @@ int epicsStrPrintEscaped(FILE *fp, const char *s, size_t len)
|
||||
if (fp == NULL)
|
||||
return -1;
|
||||
|
||||
if (s == NULL || strlen(s) == 0 || len == 0)
|
||||
if (s == NULL || len == 0)
|
||||
return 0; // No work to do
|
||||
|
||||
while (len--) {
|
||||
|
||||
@@ -119,6 +119,9 @@ LIBCOM_API char * epicsStrnDup(const char *s, size_t len);
|
||||
* \param fp File descriptor to print to
|
||||
* \param s String to print
|
||||
* \param n Length of string
|
||||
* \return Number of characters printed, or negative on error.
|
||||
*
|
||||
* \since 7.0.8 until UNRELEASED, @code strlen(s) @endcode must be valid.
|
||||
*/
|
||||
LIBCOM_API int epicsStrPrintEscaped(FILE *fp, const char *s, size_t n);
|
||||
|
||||
|
||||
@@ -220,6 +220,7 @@ void testEpicsStrPrintEscaped(void)
|
||||
|
||||
// Passing cases
|
||||
testOk1(epicsStrPrintEscaped(testFile, "1234", 4) == 4);
|
||||
testOk1(epicsStrPrintEscaped(testFile, "1234extra", 4) == 4);
|
||||
testOk1(epicsStrPrintEscaped(testFile, "\a\b\f\n\r\t\v\\\'\"", 10) == 20);
|
||||
|
||||
// Failing cases
|
||||
@@ -236,7 +237,6 @@ void testEpicsStrPrintEscaped(void)
|
||||
testSkip(1, "fprintf is broken on this system");
|
||||
}
|
||||
testOk1(epicsStrPrintEscaped(testFile, NULL, 4) == 0);
|
||||
testOk1(epicsStrPrintEscaped(testFile, "", 4) == 0);
|
||||
testOk1(epicsStrPrintEscaped(testFile, "1234", 0) == 0);
|
||||
|
||||
fclose(testFile);
|
||||
|
||||
Reference in new issue
Block a user