db: Allow single-char accesses as long strings
Clients try to use long string support to fetch DBF_STRING fields use DBF_CTRL_CHAR with a 1-element array, but the IOC was rejecting that. This permits it, and also ensures that the resulting strings are zero-terminated. Fixes lp:907761
This commit is contained in:
@@ -416,6 +416,13 @@ static long getCharChar(
|
||||
char *pbuffer = (char *)pto;
|
||||
char *psrc=(char *)(paddr->pfield);
|
||||
|
||||
if (paddr->pfldDes->field_type == DBF_STRING) {
|
||||
/* This is a DBF_STRING field being read as a long string.
|
||||
* The buffer we return must be zero-terminated.
|
||||
*/
|
||||
pbuffer[--nRequest] = 0;
|
||||
if (nRequest == 0) return(0);
|
||||
}
|
||||
if(nRequest==1 && offset==0) {
|
||||
*pbuffer = *psrc;
|
||||
return(0);
|
||||
@@ -436,6 +443,13 @@ static long getCharUchar(
|
||||
unsigned char *pbuffer = (unsigned char *)pto;
|
||||
char *psrc=(char *)(paddr->pfield);
|
||||
|
||||
if (paddr->pfldDes->field_type == DBF_STRING) {
|
||||
/* This is a DBF_STRING field being read as a long string.
|
||||
* The buffer we return must be zero-terminated.
|
||||
*/
|
||||
pbuffer[--nRequest] = 0;
|
||||
if (nRequest == 0) return(0);
|
||||
}
|
||||
if(nRequest==1 && offset==0) {
|
||||
*pbuffer = *psrc;
|
||||
return(0);
|
||||
|
||||
Reference in New Issue
Block a user