bugfix: char array access (using $ syntax) to links and attributes returned to few bytes and faild when 1 byte was requested.
This commit is contained in:
@@ -964,13 +964,14 @@ long epicsShareAPI dbGetField(DBADDR *paddr,short dbrType,
|
||||
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 @@ long epicsShareAPI dbGetField(DBADDR *paddr,short dbrType,
|
||||
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 @@ long epicsShareAPI dbGet(DBADDR *paddr, short dbrType,
|
||||
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 @@ long epicsShareAPI dbGet(DBADDR *paddr, short dbrType,
|
||||
return S_db_badDbrtype;
|
||||
}
|
||||
|
||||
strncpy(pbuf, (char *)paddr->pfield, maxlen - 1);
|
||||
pbuf[maxlen - 1] = 0;
|
||||
strncpy(pbuf, (char *)paddr->pfield, maxlen);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user