diff --git a/documentation/RELEASE_NOTES.html b/documentation/RELEASE_NOTES.html index d906ec904..bd0a375ad 100644 --- a/documentation/RELEASE_NOTES.html +++ b/documentation/RELEASE_NOTES.html @@ -13,6 +13,11 @@ +
Launchpad bug +1388313 reported by Bruce Hill and Chris Ford.
+IOC applications built for Cygwin with shared libraries need to have PATH diff --git a/src/libCom/misc/epicsString.c b/src/libCom/misc/epicsString.c index f5c61944d..4ee9fed35 100644 --- a/src/libCom/misc/epicsString.c +++ b/src/libCom/misc/epicsString.c @@ -43,6 +43,9 @@ int epicsStrnRawFromEscaped(char *to, size_t outsize, const char *from, char c; int nto = 0, nfrom = 0; + if (outsize == 0) + return 0; + while ((c = *pfrom++) && nto < outsize && nfrom < inlen) { nfrom++; if (c == '\\') { @@ -100,7 +103,9 @@ int epicsStrnRawFromEscaped(char *to, size_t outsize, const char *from, *pto++ = c; nto++; } } - *pto = '\0'; /* NOTE that nto does not have to be incremented */ + if (nto == outsize) + pto--; + *pto = '\0'; return nto; } diff --git a/src/libCom/test/epicsStringTest.c b/src/libCom/test/epicsStringTest.c index 72944f7c6..27ac53678 100644 --- a/src/libCom/test/epicsStringTest.c +++ b/src/libCom/test/epicsStringTest.c @@ -48,9 +48,11 @@ MAIN(epicsStringTest) const char * const a = "a"; const char * const abcd = "abcd"; const char * const abcde = "abcde"; + char result[8]; char *s; + int status; - testPlan(281); + testPlan(299); testChars(); @@ -85,5 +87,41 @@ MAIN(epicsStringTest) testOk1(epicsStrHash(abcd, 0) == epicsMemHash(abcde, 4, 0)); testOk1(epicsStrHash(abcd, 0) != epicsMemHash("abcd\0", 5, 0)); + memset(result, 'x', sizeof(result)); + status = epicsStrnEscapedFromRaw(result, 4, ABCD, 3); + testOk(status == 3, "epicsStrnEscapedFromRaw returned %d (exp. 3)", status); + testOk(result[4] == 'x', "epicsStrnEscapedFromRaw no buffer overrun"); + testOk(result[3] == 0, "epicsStrnEscapedFromRaw 0-terminated"); + + memset(result, 'x', sizeof(result)); + status = epicsStrnEscapedFromRaw(result, 4, ABCD, 4); + testOk(status == 4, "epicsStrnEscapedFromRaw returned %d (exp. 4)", status); + testOk(result[4] == 'x', "epicsStrnEscapedFromRaw no buffer overrun"); + testOk(result[3] == 0, "epicsStrnEscapedFromRaw 0-terminated"); + + memset(result, 'x', sizeof(result)); + status = epicsStrnEscapedFromRaw(result, 4, ABCDE, 5); + testOk(status == 5, "epicsStrnEscapedFromRaw returned %d (exp. 5)", status); + testOk(result[4] == 'x', "epicsStrnEscapedFromRaw no buffer overrun"); + testOk(result[3] == 0, "epicsStrnEscapedFromRaw 0-terminated"); + + memset(result, 'x', sizeof(result)); + status = epicsStrnRawFromEscaped(result, 4, ABCD, 3); + testOk(status == 3, "epicsStrnRawFromEscaped returned %d (exp. 3)", status); + testOk(result[4] == 'x', "epicsStrnRawFromEscaped no buffer overrun"); + testOk(result[3] == 0, "epicsStrnRawFromEscaped 0-terminated"); + + memset(result, 'x', sizeof(result)); + status = epicsStrnRawFromEscaped(result, 4, ABCD, 4); + testOk(status == 4, "epicsStrnRawFromEscaped returned %d (exp. 4)", status); + testOk(result[4] == 'x', "epicsStrnRawFromEscaped no buffer overrun"); + testOk(result[3] == 0, "epicsStrnRawFromEscaped 0-terminated"); + + memset(result, 'x', sizeof(result)); + status = epicsStrnRawFromEscaped(result, 4, ABCDE, 5); + testOk(status == 4, "epicsStrnRawFromEscaped returned %d (exp. 4)", status); + testOk(result[4] == 'x', "epicsStrnRawFromEscaped no buffer overrun"); + testOk(result[3] == 0, "epicsStrnRawFromEscaped 0-terminated"); + return testDone(); }