Index: src/db/dbAccess.c =================================================================== RCS file: /cvs/G/EPICS/base-3.14.12/src/db/dbAccess.c,v retrieving revision 1.1.1.1 diff -u -r1.1.1.1 dbAccess.c --- src/db/dbAccess.c 29 Nov 2010 10:38:07 -0000 1.1.1.1 +++ src/db/dbAccess.c 23 Dec 2011 10:25:26 -0000 @@ -964,13 +964,14 @@ switch (dbrType) { case DBR_STRING: maxlen = MAX_STRING_SIZE - 1; + pbuf[maxlen] = 0; if (nRequest && *nRequest > 1) *nRequest = 1; break; case DBR_CHAR: case DBR_UCHAR: - if (nRequest && *nRequest > 1) { - maxlen = *nRequest - 1; + if (nRequest && *nRequest > 0) { + maxlen = *nRequest; break; } /* else fall through ... */ @@ -984,8 +985,7 @@ if (!status) status = dbFindField(&dbEntry, pfldDes->name); if (!status) { rtnString = dbGetString(&dbEntry); - strncpy(pbuf, rtnString, maxlen - 1); - pbuf[maxlen - 1] = 0; + strncpy(pbuf, rtnString, maxlen); } dbFinishEntry(&dbEntry); } else { @@ -1023,13 +1023,14 @@ switch (dbrType) { case DBR_STRING: maxlen = MAX_STRING_SIZE - 1; + pbuf[maxlen] = 0; if (nRequest && *nRequest > 1) *nRequest = 1; break; case DBR_CHAR: case DBR_UCHAR: - if (nRequest && *nRequest > 1) { - maxlen = *nRequest - 1; + if (nRequest && *nRequest > 0) { + maxlen = *nRequest; break; } /* else fall through ... */ @@ -1037,8 +1038,7 @@ return S_db_badDbrtype; } - strncpy(pbuf, (char *)paddr->pfield, maxlen - 1); - pbuf[maxlen - 1] = 0; + strncpy(pbuf, (char *)paddr->pfield, maxlen); return 0; }